2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define NONAMELESSUNION
23 #include <wine/test.h>
34 DEFINE_GUID(CLSID_AboutProtocol
, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
36 #define DEFINE_EXPECT(func) \
37 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
39 #define SET_EXPECT(func) \
40 expect_ ## func = TRUE
42 #define CHECK_EXPECT(func) \
44 ok(expect_ ##func, "unexpected call " #func "\n"); \
45 expect_ ## func = FALSE; \
46 called_ ## func = TRUE; \
49 #define CHECK_EXPECT2(func) \
51 ok(expect_ ##func, "unexpected call " #func "\n"); \
52 called_ ## func = TRUE; \
55 #define CHECK_CALLED(func) \
57 ok(called_ ## func, "expected " #func "\n"); \
58 expect_ ## func = called_ ## func = FALSE; \
61 DEFINE_EXPECT(ParseUrl
);
62 DEFINE_EXPECT(QI_IInternetProtocolInfo
);
63 DEFINE_EXPECT(CreateInstance
);
64 DEFINE_EXPECT(unk_Release
);
66 static HRESULT (WINAPI
*pCoInternetCompareUrl
)(LPCWSTR
, LPCWSTR
, DWORD
);
67 static HRESULT (WINAPI
*pCoInternetGetSecurityUrl
)(LPCWSTR
, LPWSTR
*, PSUACTION
, DWORD
);
68 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
69 static HRESULT (WINAPI
*pCoInternetParseUrl
)(LPCWSTR
, PARSEACTION
, DWORD
, LPWSTR
, DWORD
, DWORD
*, DWORD
);
70 static HRESULT (WINAPI
*pCoInternetQueryInfo
)(LPCWSTR
, QUERYOPTION
, DWORD
, LPVOID
, DWORD
, DWORD
*, DWORD
);
71 static HRESULT (WINAPI
*pCopyStgMedium
)(const STGMEDIUM
*, STGMEDIUM
*);
72 static HRESULT (WINAPI
*pCopyBindInfo
)(const BINDINFO
*, BINDINFO
*);
73 static HRESULT (WINAPI
*pFindMimeFromData
)(LPBC
, LPCWSTR
, LPVOID
, DWORD
, LPCWSTR
,
74 DWORD
, LPWSTR
*, DWORD
);
75 static HRESULT (WINAPI
*pObtainUserAgentString
)(DWORD
, LPSTR
, DWORD
*);
76 static HRESULT (WINAPI
*pReleaseBindInfo
)(BINDINFO
*);
77 static HRESULT (WINAPI
*pUrlMkGetSessionOption
)(DWORD
, LPVOID
, DWORD
, DWORD
*, DWORD
);
78 static HRESULT (WINAPI
*pCompareSecurityIds
)(BYTE
*,DWORD
,BYTE
*,DWORD
,DWORD
);
79 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabled
)(INTERNETFEATURELIST
,DWORD
);
80 static HRESULT (WINAPI
*pCoInternetSetFeatureEnabled
)(INTERNETFEATURELIST
,DWORD
,BOOL
);
81 static HRESULT (WINAPI
*pIEInstallScope
)(DWORD
*);
83 static void test_CreateFormatEnum(void)
85 IEnumFORMATETC
*fenum
= NULL
, *fenum2
= NULL
;
90 static DVTARGETDEVICE dev
= {sizeof(dev
),0,0,0,0,{0}};
91 static FORMATETC formatetc
[] = {
99 hres
= CreateFormatEnumerator(0, formatetc
, &fenum
);
100 ok(hres
== E_FAIL
, "CreateFormatEnumerator failed: %08x, expected E_FAIL\n", hres
);
101 hres
= CreateFormatEnumerator(0, formatetc
, NULL
);
102 ok(hres
== E_INVALIDARG
, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
103 hres
= CreateFormatEnumerator(5, formatetc
, NULL
);
104 ok(hres
== E_INVALIDARG
, "CreateFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
107 hres
= CreateFormatEnumerator(5, formatetc
, &fenum
);
108 ok(hres
== S_OK
, "CreateFormatEnumerator failed: %08x\n", hres
);
112 hres
= IEnumFORMATETC_Next(fenum
, 2, NULL
, &ul
);
113 ok(hres
== E_INVALIDARG
, "Next failed: %08x, expected E_INVALIDARG\n", hres
);
115 hres
= IEnumFORMATETC_Next(fenum
, 0, fetc
, &ul
);
116 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
117 ok(ul
== 0, "ul=%d, expected 0\n", ul
);
119 hres
= IEnumFORMATETC_Next(fenum
, 2, fetc
, &ul
);
120 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
121 ok(fetc
[0].lindex
== 0, "fetc[0].lindex=%d, expected 0\n", fetc
[0].lindex
);
122 ok(fetc
[1].lindex
== 1, "fetc[1].lindex=%d, expected 1\n", fetc
[1].lindex
);
123 ok(fetc
[0].ptd
== &dev
, "fetc[0].ptd=%p, expected %p\n", fetc
[0].ptd
, &dev
);
124 ok(ul
== 2, "ul=%d, expected 2\n", ul
);
126 hres
= IEnumFORMATETC_Skip(fenum
, 1);
127 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
129 hres
= IEnumFORMATETC_Next(fenum
, 4, fetc
, &ul
);
130 ok(hres
== S_FALSE
, "Next failed: %08x, expected S_FALSE\n", hres
);
131 ok(fetc
[0].lindex
== 3, "fetc[0].lindex=%d, expected 3\n", fetc
[0].lindex
);
132 ok(fetc
[1].lindex
== 4, "fetc[1].lindex=%d, expected 4\n", fetc
[1].lindex
);
133 ok(fetc
[0].ptd
== NULL
, "fetc[0].ptd=%p, expected NULL\n", fetc
[0].ptd
);
134 ok(ul
== 2, "ul=%d, expected 2\n", ul
);
136 hres
= IEnumFORMATETC_Next(fenum
, 4, fetc
, &ul
);
137 ok(hres
== S_FALSE
, "Next failed: %08x, expected S_FALSE\n", hres
);
138 ok(ul
== 0, "ul=%d, expected 0\n", ul
);
140 hres
= IEnumFORMATETC_Next(fenum
, 0, fetc
, &ul
);
141 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
142 ok(ul
== 0, "ul=%d, expected 0\n", ul
);
144 hres
= IEnumFORMATETC_Skip(fenum
, 3);
145 ok(hres
== S_FALSE
, "Skip failed: %08x, expected S_FALSE\n", hres
);
147 hres
= IEnumFORMATETC_Reset(fenum
);
148 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
150 hres
= IEnumFORMATETC_Next(fenum
, 5, fetc
, NULL
);
151 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
152 ok(fetc
[0].lindex
== 0, "fetc[0].lindex=%d, expected 0\n", fetc
[0].lindex
);
154 hres
= IEnumFORMATETC_Reset(fenum
);
155 ok(hres
== S_OK
, "Reset failed: %08x\n", hres
);
157 hres
= IEnumFORMATETC_Skip(fenum
, 2);
158 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
160 hres
= IEnumFORMATETC_Clone(fenum
, NULL
);
161 ok(hres
== E_INVALIDARG
, "Clone failed: %08x, expected E_INVALIDARG\n", hres
);
163 hres
= IEnumFORMATETC_Clone(fenum
, &fenum2
);
164 ok(hres
== S_OK
, "Clone failed: %08x\n", hres
);
166 if(SUCCEEDED(hres
)) {
167 ok(fenum
!= fenum2
, "fenum == fenum2\n");
169 hres
= IEnumFORMATETC_Next(fenum2
, 2, fetc
, &ul
);
170 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
171 ok(fetc
[0].lindex
== 2, "fetc[0].lindex=%d, expected 2\n", fetc
[0].lindex
);
173 IEnumFORMATETC_Release(fenum2
);
176 hres
= IEnumFORMATETC_Next(fenum
, 2, fetc
, &ul
);
177 ok(hres
== S_OK
, "Next failed: %08x\n", hres
);
178 ok(fetc
[0].lindex
== 2, "fetc[0].lindex=%d, expected 2\n", fetc
[0].lindex
);
180 hres
= IEnumFORMATETC_Skip(fenum
, 1);
181 ok(hres
== S_OK
, "Skip failed: %08x\n", hres
);
183 IEnumFORMATETC_Release(fenum
);
186 static void test_RegisterFormatEnumerator(void)
188 IBindCtx
*bctx
= NULL
;
189 IEnumFORMATETC
*format
= NULL
, *format2
= NULL
;
190 IUnknown
*unk
= NULL
;
193 static FORMATETC formatetc
= {0,NULL
,0,0,0};
194 static WCHAR wszEnumFORMATETC
[] =
195 {'_','E','n','u','m','F','O','R','M','A','T','E','T','C','_',0};
197 CreateBindCtx(0, &bctx
);
199 hres
= CreateFormatEnumerator(1, &formatetc
, &format
);
200 ok(hres
== S_OK
, "CreateFormatEnumerator failed: %08x\n", hres
);
204 hres
= RegisterFormatEnumerator(NULL
, format
, 0);
205 ok(hres
== E_INVALIDARG
,
206 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
207 hres
= RegisterFormatEnumerator(bctx
, NULL
, 0);
208 ok(hres
== E_INVALIDARG
,
209 "RegisterFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
211 hres
= RegisterFormatEnumerator(bctx
, format
, 0);
212 ok(hres
== S_OK
, "RegisterFormatEnumerator failed: %08x\n", hres
);
214 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
215 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
216 ok(unk
== (IUnknown
*)format
, "unk != format\n");
218 hres
= RevokeFormatEnumerator(NULL
, format
);
219 ok(hres
== E_INVALIDARG
,
220 "RevokeFormatEnumerator failed: %08x, expected E_INVALIDARG\n", hres
);
222 hres
= RevokeFormatEnumerator(bctx
, format
);
223 ok(hres
== S_OK
, "RevokeFormatEnumerator failed: %08x\n", hres
);
225 hres
= RevokeFormatEnumerator(bctx
, format
);
226 ok(hres
== E_FAIL
, "RevokeFormatEnumerator failed: %08x, expected E_FAIL\n", hres
);
228 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
229 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x, expected E_FAIL\n", hres
);
231 hres
= RegisterFormatEnumerator(bctx
, format
, 0);
232 ok(hres
== S_OK
, "RegisterFormatEnumerator failed: %08x\n", hres
);
234 hres
= CreateFormatEnumerator(1, &formatetc
, &format2
);
235 ok(hres
== S_OK
, "CreateFormatEnumerator failed: %08x\n", hres
);
237 if(SUCCEEDED(hres
)) {
238 hres
= RevokeFormatEnumerator(bctx
, format
);
239 ok(hres
== S_OK
, "RevokeFormatEnumerator failed: %08x\n", hres
);
241 IEnumFORMATETC_Release(format2
);
244 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
245 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x, expected E_FAIL\n", hres
);
247 IEnumFORMATETC_Release(format
);
249 hres
= RegisterFormatEnumerator(bctx
, format
, 0);
250 ok(hres
== S_OK
, "RegisterFormatEnumerator failed: %08x\n", hres
);
251 hres
= RevokeFormatEnumerator(bctx
, NULL
);
252 ok(hres
== S_OK
, "RevokeFormatEnumerator failed: %08x\n", hres
);
253 hres
= IBindCtx_GetObjectParam(bctx
, wszEnumFORMATETC
, &unk
);
254 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x, expected E_FAIL\n", hres
);
256 IEnumFORMATETC_Release(format
);
257 IBindCtx_Release(bctx
);
260 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
261 '/','b','l','a','n','k','.','h','t','m',0};
262 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
263 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
264 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
265 '%','2','e','j','p','g',0};
266 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
268 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
269 static const WCHAR url7
[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
270 'f','i','l','e','.','t','e','s','t',0};
271 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
272 static const WCHAR url9
[] =
273 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',
274 '/','s','i','t','e','/','a','b','o','u','t',0};
275 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
277 static const WCHAR url11
[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','*','.',
279 static const WCHAR url4e
[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
282 static const WCHAR path3
[] = {'c',':','\\','I','n','d','e','x','.','h','t','m',0};
283 static const WCHAR path4
[] = {'s','o','m','e',' ','f','i','l','e','.','j','p','g',0};
285 static const WCHAR wszRes
[] = {'r','e','s',0};
286 static const WCHAR wszFile
[] = {'f','i','l','e',0};
287 static const WCHAR wszHttp
[] = {'h','t','t','p',0};
288 static const WCHAR wszAbout
[] = {'a','b','o','u','t',0};
289 static const WCHAR wszEmpty
[] = {0};
290 static const WCHAR wszGoogle
[] = {'g','o','o','g','l','e','.','*','.','c','o','m',0};
292 static const WCHAR wszWineHQ
[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
293 static const WCHAR wszHttpWineHQ
[] = {'h','t','t','p',':','/','/','w','w','w','.',
294 'w','i','n','e','h','q','.','o','r','g',0};
295 static const WCHAR wszHttpGoogle
[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e',
296 '.','*','.','c','o','m',0};
307 LPCWSTR rootdocument
;
308 HRESULT rootdocument_hres
;
311 static const struct parse_test parse_tests
[] = {
312 {url1
, S_OK
, url1
, E_INVALIDARG
, NULL
, wszRes
, NULL
, E_FAIL
, NULL
, E_FAIL
},
313 {url2
, E_FAIL
, url2
, E_INVALIDARG
, NULL
, wszEmpty
, NULL
, E_FAIL
, NULL
, E_FAIL
},
314 {url3
, E_FAIL
, url3
, S_OK
, path3
, wszFile
, wszEmpty
, S_OK
, NULL
, E_FAIL
},
315 {url4
, E_FAIL
, url4e
, S_OK
, path4
, wszFile
, wszEmpty
, S_OK
, NULL
, E_FAIL
},
316 {url5
, E_FAIL
, url5
, E_INVALIDARG
, NULL
, wszHttp
, wszWineHQ
, S_OK
, wszHttpWineHQ
, S_OK
},
317 {url6
, S_OK
, url6
, E_INVALIDARG
, NULL
, wszAbout
, NULL
, E_FAIL
, NULL
, E_FAIL
},
318 {url11
, E_FAIL
, url11
, E_INVALIDARG
, NULL
, wszHttp
, wszGoogle
, S_OK
, wszHttpGoogle
, S_OK
}
321 static void test_CoInternetParseUrl(void)
327 static WCHAR buf
[4096];
329 memset(buf
, 0xf0, sizeof(buf
));
330 hres
= pCoInternetParseUrl(parse_tests
[0].url
, PARSE_SCHEMA
, 0, buf
,
332 ok(hres
== E_POINTER
, "schema failed: %08x, expected E_POINTER\n", hres
);
334 for(i
=0; i
< sizeof(parse_tests
)/sizeof(parse_tests
[0]); i
++) {
335 memset(buf
, 0xf0, sizeof(buf
));
336 hres
= pCoInternetParseUrl(parse_tests
[i
].url
, PARSE_SECURITY_URL
, 0, buf
,
337 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
338 ok(hres
== parse_tests
[i
].secur_hres
, "[%d] security url failed: %08x, expected %08x\n",
339 i
, hres
, parse_tests
[i
].secur_hres
);
341 memset(buf
, 0xf0, sizeof(buf
));
342 hres
= pCoInternetParseUrl(parse_tests
[i
].url
, PARSE_ENCODE
, 0, buf
,
343 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
344 ok(hres
== S_OK
, "[%d] encoding failed: %08x\n", i
, hres
);
345 ok(size
== lstrlenW(parse_tests
[i
].encoded_url
), "[%d] wrong size\n", i
);
346 ok(!lstrcmpW(parse_tests
[i
].encoded_url
, buf
), "[%d] wrong encoded url\n", i
);
348 memset(buf
, 0xf0, sizeof(buf
));
349 hres
= pCoInternetParseUrl(parse_tests
[i
].url
, PARSE_PATH_FROM_URL
, 0, buf
,
350 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
351 ok(hres
== parse_tests
[i
].path_hres
, "[%d] path failed: %08x, expected %08x\n",
352 i
, hres
, parse_tests
[i
].path_hres
);
353 if(parse_tests
[i
].path
) {
354 ok(size
== lstrlenW(parse_tests
[i
].path
), "[%d] wrong size\n", i
);
355 ok(!lstrcmpW(parse_tests
[i
].path
, buf
), "[%d] wrong path\n", i
);
358 memset(buf
, 0xf0, sizeof(buf
));
359 hres
= pCoInternetParseUrl(parse_tests
[i
].url
, PARSE_SCHEMA
, 0, buf
,
360 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
361 ok(hres
== S_OK
, "[%d] schema failed: %08x\n", i
, hres
);
362 ok(size
== lstrlenW(parse_tests
[i
].schema
), "[%d] wrong size\n", i
);
363 ok(!lstrcmpW(parse_tests
[i
].schema
, buf
), "[%d] wrong schema\n", i
);
365 if(memcmp(parse_tests
[i
].url
, wszRes
, 3*sizeof(WCHAR
))
366 && memcmp(parse_tests
[i
].url
, wszAbout
, 5*sizeof(WCHAR
))) {
367 memset(buf
, 0xf0, sizeof(buf
));
368 hres
= pCoInternetParseUrl(parse_tests
[i
].url
, PARSE_DOMAIN
, 0, buf
,
369 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
370 ok(hres
== parse_tests
[i
].domain_hres
, "[%d] domain failed: %08x\n", i
, hres
);
371 if(parse_tests
[i
].domain
)
372 ok(!lstrcmpW(parse_tests
[i
].domain
, buf
), "[%d] wrong domain, received %s\n", i
, wine_dbgstr_w(buf
));
375 memset(buf
, 0xf0, sizeof(buf
));
376 hres
= pCoInternetParseUrl(parse_tests
[i
].url
, PARSE_ROOTDOCUMENT
, 0, buf
,
377 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
378 ok(hres
== parse_tests
[i
].rootdocument_hres
, "[%d] rootdocument failed: %08x\n", i
, hres
);
379 if(parse_tests
[i
].rootdocument
)
380 ok(!lstrcmpW(parse_tests
[i
].rootdocument
, buf
), "[%d] wrong rootdocument, received %s\n", i
, wine_dbgstr_w(buf
));
384 static void test_CoInternetCompareUrl(void)
388 hres
= pCoInternetCompareUrl(url1
, url1
, 0);
389 ok(hres
== S_OK
, "CoInternetCompareUrl failed: %08x\n", hres
);
391 hres
= pCoInternetCompareUrl(url1
, url3
, 0);
392 ok(hres
== S_FALSE
, "CoInternetCompareUrl failed: %08x\n", hres
);
394 hres
= pCoInternetCompareUrl(url3
, url1
, 0);
395 ok(hres
== S_FALSE
, "CoInternetCompareUrl failed: %08x\n", hres
);
398 static const struct {
401 } query_info_tests
[] = {
412 static void test_CoInternetQueryInfo(void)
418 for(i
=0; i
< sizeof(query_info_tests
)/sizeof(query_info_tests
[0]); i
++) {
420 memset(buf
, '?', sizeof(buf
));
421 hres
= pCoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, buf
, sizeof(buf
), &cb
, 0);
422 ok(hres
== S_OK
, "[%d] CoInternetQueryInfo failed: %08x\n", i
, hres
);
423 ok(cb
== sizeof(DWORD
), "[%d] cb = %d\n", i
, cb
);
424 ok(*(DWORD
*)buf
== query_info_tests
[i
].uses_net
, "[%d] ret %x, expected %x\n",
425 i
, *(DWORD
*)buf
, query_info_tests
[i
].uses_net
);
427 hres
= pCoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, buf
, 3, &cb
, 0);
428 ok(hres
== E_FAIL
, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i
, hres
);
429 hres
= pCoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, NULL
, sizeof(buf
), &cb
, 0);
430 ok(hres
== E_FAIL
, "[%d] CoInternetQueryInfo failed: %08x, expected E_FAIL\n", i
, hres
);
432 memset(buf
, '?', sizeof(buf
));
433 hres
= pCoInternetQueryInfo(query_info_tests
[0].url
, QUERY_USES_NETWORK
, 0, buf
, sizeof(buf
), NULL
, 0);
434 ok(hres
== S_OK
, "[%d] CoInternetQueryInfo failed: %08x\n", i
, hres
);
435 ok(*(DWORD
*)buf
== query_info_tests
[i
].uses_net
, "[%d] ret %x, expected %x\n",
436 i
, *(DWORD
*)buf
, query_info_tests
[i
].uses_net
);
440 static const WCHAR mimeTextHtml
[] = {'t','e','x','t','/','h','t','m','l',0};
441 static const WCHAR mimeTextPlain
[] = {'t','e','x','t','/','p','l','a','i','n',0};
442 static const WCHAR mimeTextRichtext
[] = {'t','e','x','t','/','r','i','c','h','t','e','x','t',0};
443 static const WCHAR mimeTextXml
[] = {'t','e','x','t','/','x','m','l',0};
444 static const WCHAR mimeAppOctetStream
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
445 'o','c','t','e','t','-','s','t','r','e','a','m',0};
446 static const WCHAR mimeImagePjpeg
[] = {'i','m','a','g','e','/','p','j','p','e','g',0};
447 static const WCHAR mimeImageGif
[] = {'i','m','a','g','e','/','g','i','f',0};
448 static const WCHAR mimeImageBmp
[] = {'i','m','a','g','e','/','b','m','p',0};
449 static const WCHAR mimeImageXPng
[] = {'i','m','a','g','e','/','x','-','p','n','g',0};
450 static const WCHAR mimeImageTiff
[] = {'i','m','a','g','e','/','t','i','f','f',0};
451 static const WCHAR mimeVideoAvi
[] = {'v','i','d','e','o','/','a','v','i',0};
452 static const WCHAR mimeVideoMpeg
[] = {'v','i','d','e','o','/','m','p','e','g',0};
453 static const WCHAR mimeAppPostscript
[] =
454 {'a','p','p','l','i','c','a','t','i','o','n','/','p','o','s','t','s','c','r','i','p','t',0};
455 static const WCHAR mimeAppXCompressed
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
456 'x','-','c','o','m','p','r','e','s','s','e','d',0};
457 static const WCHAR mimeAppXZip
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
458 'x','-','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
459 static const WCHAR mimeAppXGzip
[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
460 'x','-','g','z','i','p','-','c','o','m','p','r','e','s','s','e','d',0};
461 static const WCHAR mimeAppJava
[] = {'a','p','p','l','i','c','a','t','i','o','n','/','j','a','v','a',0};
462 static const WCHAR mimeAppPdf
[] = {'a','p','p','l','i','c','a','t','i','o','n','/','p','d','f',0};
463 static const WCHAR mimeAppXMSDownload
[] =
464 {'a','p','p','l','i','c','a','t','i','o','n','/','x','-','m','s','d','o','w','n','l','o','a','d',0};
465 static const WCHAR mimeAudioWav
[] = {'a','u','d','i','o','/','w','a','v',0};
466 static const WCHAR mimeAudioBasic
[] = {'a','u','d','i','o','/','b','a','s','i','c',0};
468 static const struct {
473 {url1
, mimeTextHtml
, S_OK
},
474 {url2
, mimeTextHtml
, S_OK
},
475 {url3
, mimeTextHtml
, S_OK
},
476 {url4
, NULL
, E_FAIL
},
477 {url5
, NULL
, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)},
478 {url6
, NULL
, E_FAIL
},
479 {url7
, NULL
, __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
)}
482 static BYTE data1
[] = "test data\n";
483 static BYTE data2
[] = {31,'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0};
484 static BYTE data3
[] = {0,0,0};
485 static BYTE data4
[] = {'t','e','s',0xfa,'t',' ','d','a','t','a','\n',0,0};
486 static BYTE data5
[] = {0xa,0xa,0xa,'x',32,'x',0};
487 static BYTE data6
[] = {0xfa,0xfa,0xfa,0xfa,'\n','\r','\t','x','x','x',1};
488 static BYTE data7
[] = "<html>blahblah";
489 static BYTE data8
[] = {'t','e','s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
490 static BYTE data9
[] = {'t','e',0,'s',0xfa,'t',' ','<','h','t','m','l','>','d','a','t','a','\n',0,0};
491 static BYTE data10
[] = "<HtmL>blahblah";
492 static BYTE data11
[] = "blah<HTML>blahblah";
493 static BYTE data12
[] = "blah<HTMLblahblah";
494 static BYTE data13
[] = "blahHTML>blahblah";
495 static BYTE data14
[] = "blah<HTMblahblah";
496 static BYTE data15
[] = {0xff,0xd8};
497 static BYTE data16
[] = {0xff,0xd8,'h'};
498 static BYTE data17
[] = {0,0xff,0xd8};
499 static BYTE data18
[] = {0xff,0xd8,'<','h','t','m','l','>'};
500 static BYTE data19
[] = {'G','I','F','8','7','a'};
501 static BYTE data20
[] = {'G','I','F','8','9','a'};
502 static BYTE data21
[] = {'G','I','F','8','7'};
503 static BYTE data22
[] = {'G','i','F','8','7','a'};
504 static BYTE data23
[] = {'G','i','F','8','8','a'};
505 static BYTE data24
[] = {'g','i','f','8','7','a'};
506 static BYTE data25
[] = {'G','i','F','8','7','A'};
507 static BYTE data26
[] = {'G','i','F','8','7','a','<','h','t','m','l','>'};
508 static BYTE data27
[] = {0x30,'G','i','F','8','7','A'};
509 static BYTE data28
[] = {0x42,0x4d,0x6e,0x42,0x1c,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x00,0x00};
510 static BYTE data29
[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x','x'};
511 static BYTE data30
[] = {0x42,0x4d,'x','x','x','x',0x00,0x01,0x00,0x00,'x','x','x','x'};
512 static BYTE data31
[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'<','h','t','m','l','>'};
513 static BYTE data32
[] = {0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
514 static BYTE data33
[] = {0x00,0x42,0x4d,'x','x','x','x',0x00,0x00,0x00,0x00,'x','x','x'};
515 static BYTE data34
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
516 static BYTE data35
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x','x','x','x',0};
517 static BYTE data36
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,'x','x'};
518 static BYTE data37
[] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'<','h','t','m','l','>'};
519 static BYTE data38
[] = {0x00,0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a,'x'};
520 static BYTE data39
[] = {0x4d,0x4d,0x00,0x2a,0xff};
521 static BYTE data40
[] = {0x4d,0x4d,0x00,0x2a,'<','h','t','m','l','>',0};
522 static BYTE data41
[] = {0x4d,0x4d,0xff};
523 static BYTE data42
[] = {0x4d,0x4d};
524 static BYTE data43
[] = {0x00,0x4d,0x4d,0x00};
525 static BYTE data44
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
526 static BYTE data45
[] = {'R','I','F','f',0xff,0xff,0xff,0xff,'A','V','I',0x20,0xff};
527 static BYTE data46
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20};
528 static BYTE data47
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x21,0xff};
529 static BYTE data48
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'A','V','I',0x20,'<','h','t','m','l','>'};
530 static BYTE data49
[] = {'R','I','F','F',0x0f,0x0f,0xf0,0xf0,'A','V','I',0x20,0xf0,0x00};
531 static BYTE data50
[] = {0x00,0x00,0x01,0xb3,0xff};
532 static BYTE data51
[] = {0x00,0x00,0x01,0xba,0xff};
533 static BYTE data52
[] = {0x00,0x00,0x01,0xb8,0xff};
534 static BYTE data53
[] = {0x00,0x00,0x01,0xba};
535 static BYTE data54
[] = {0x00,0x00,0x01,0xba,'<','h','t','m','l','>'};
536 static BYTE data55
[] = {0x1f,0x8b,'x'};
537 static BYTE data56
[] = {0x1f};
538 static BYTE data57
[] = {0x1f,0x8b,'<','h','t','m','l','>','t','e','s','t',0};
539 static BYTE data58
[] = {0x1f,0x8b};
540 static BYTE data59
[] = {0x50,0x4b,'x'};
541 static BYTE data60
[] = {0x50,0x4b};
542 static BYTE data61
[] = {0x50,0x4b,'<','h','t','m','l','>',0};
543 static BYTE data62
[] = {0xca,0xfe,0xba,0xbe,'x'};
544 static BYTE data63
[] = {0xca,0xfe,0xba,0xbe};
545 static BYTE data64
[] = {0xca,0xfe,0xba,0xbe,'<','h','t','m','l','>',0};
546 static BYTE data65
[] = {0x25,0x50,0x44,0x46,'x'};
547 static BYTE data66
[] = {0x25,0x50,0x44,0x46};
548 static BYTE data67
[] = {0x25,0x50,0x44,0x46,'x','<','h','t','m','l','>'};
549 static BYTE data68
[] = {'M','Z','x'};
550 static BYTE data69
[] = {'M','Z'};
551 static BYTE data70
[] = {'M','Z','<','h','t','m','l','>',0xff};
552 static BYTE data71
[] = {'{','\\','r','t','f',0};
553 static BYTE data72
[] = {'{','\\','r','t','f'};
554 static BYTE data73
[] = {' ','{','\\','r','t','f',' '};
555 static BYTE data74
[] = {'{','\\','r','t','f','<','h','t','m','l','>',' '};
556 static BYTE data75
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E',0xff};
557 static BYTE data76
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V','E'};
558 static BYTE data77
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'W','A','V',0xff,0xff};
559 static BYTE data78
[] = {'R','I','F','F',0xff,0xff,0xff,0xff,'<','h','t','m','l','>',0xff};
560 static BYTE data79
[] = {'%','!',0xff};
561 static BYTE data80
[] = {'%','!'};
562 static BYTE data81
[] = {'%','!','P','S','<','h','t','m','l','>'};
563 static BYTE data82
[] = {'.','s','n','d',0};
564 static BYTE data83
[] = {'.','s','n','d'};
565 static BYTE data84
[] = {'.','s','n','d',0,'<','h','t','m','l','>',1,1};
566 static BYTE data85
[] = {'.','S','N','D',0};
567 static BYTE data86
[] = {0x49,0x49,0x2a,0xff};
568 static BYTE data87
[] = {' ','<','h','e','a','d'};
569 static BYTE data88
[] = {' ','<','h','e','a','d','>'};
570 static BYTE data89
[] = {'\t','\r','<','h','e','a','d','>'};
571 static BYTE data90
[] = {'<','H','e','A','d',' '};
572 static BYTE data91
[] = {'<','?','x','m','l',' ',0};
573 static BYTE data92
[] = {'a','b','c','<','?','x','m','l',' ',' '};
574 static BYTE data93
[] = {'<','?','x','m','l',' ',' ','<','h','t','m','l','>'};
575 static BYTE data94
[] = {'<','h','t','m','l','>','<','?','x','m','l',' ',' '};
576 static BYTE data95
[] = {'{','\\','r','t','f','<','?','x','m','l',' ',' '};
577 static BYTE data96
[] = {'<','?','x','m','l',' '};
579 static const struct {
582 LPCWSTR mime
, mime_pjpeg
, broken_mime
;
584 {data1
, sizeof(data1
), mimeTextPlain
, mimeTextPlain
},
585 {data2
, sizeof(data2
), mimeAppOctetStream
, mimeImagePjpeg
},
586 {data3
, sizeof(data3
), mimeAppOctetStream
, mimeImagePjpeg
},
587 {data4
, sizeof(data4
), mimeAppOctetStream
, mimeImagePjpeg
},
588 {data5
, sizeof(data5
), mimeTextPlain
, mimeTextPlain
},
589 {data6
, sizeof(data6
), mimeTextPlain
, mimeTextPlain
},
590 {data7
, sizeof(data7
), mimeTextHtml
, mimeTextPlain
},
591 {data8
, sizeof(data8
), mimeTextHtml
, mimeTextPlain
},
592 {data9
, sizeof(data9
), mimeTextHtml
, mimeImagePjpeg
},
593 {data10
, sizeof(data10
), mimeTextHtml
, mimeTextPlain
},
594 {data11
, sizeof(data11
), mimeTextHtml
, mimeTextPlain
},
595 {data12
, sizeof(data12
), mimeTextHtml
, mimeTextPlain
},
596 {data13
, sizeof(data13
), mimeTextPlain
, mimeTextPlain
},
597 {data14
, sizeof(data14
), mimeTextPlain
, mimeTextPlain
},
598 {data15
, sizeof(data15
), mimeTextPlain
, mimeTextPlain
},
599 {data16
, sizeof(data16
), mimeImagePjpeg
, mimeImagePjpeg
},
600 {data17
, sizeof(data17
), mimeAppOctetStream
, mimeImagePjpeg
},
601 {data18
, sizeof(data18
), mimeTextHtml
, mimeImagePjpeg
},
602 {data19
, sizeof(data19
), mimeImageGif
, mimeImageGif
},
603 {data20
, sizeof(data20
), mimeImageGif
, mimeImageGif
},
604 {data21
, sizeof(data21
), mimeTextPlain
, mimeTextPlain
},
605 {data22
, sizeof(data22
), mimeImageGif
, mimeImageGif
},
606 {data23
, sizeof(data23
), mimeTextPlain
, mimeTextPlain
},
607 {data24
, sizeof(data24
), mimeImageGif
, mimeImageGif
},
608 {data25
, sizeof(data25
), mimeImageGif
, mimeImageGif
},
609 {data26
, sizeof(data26
), mimeTextHtml
, mimeImageGif
},
610 {data27
, sizeof(data27
), mimeTextPlain
, mimeTextPlain
},
611 {data28
, sizeof(data28
), mimeImageBmp
, mimeImageBmp
},
612 {data29
, sizeof(data29
), mimeImageBmp
, mimeImageBmp
},
613 {data30
, sizeof(data30
), mimeAppOctetStream
, mimeImagePjpeg
},
614 {data31
, sizeof(data31
), mimeTextHtml
, mimeImageBmp
},
615 {data32
, sizeof(data32
), mimeAppOctetStream
, mimeImagePjpeg
},
616 {data33
, sizeof(data33
), mimeAppOctetStream
, mimeImagePjpeg
},
617 {data34
, sizeof(data34
), mimeImageXPng
, mimeImageXPng
},
618 {data35
, sizeof(data35
), mimeImageXPng
, mimeImageXPng
},
619 {data36
, sizeof(data36
), mimeAppOctetStream
, mimeImagePjpeg
},
620 {data37
, sizeof(data37
), mimeTextHtml
, mimeImageXPng
},
621 {data38
, sizeof(data38
), mimeAppOctetStream
, mimeImagePjpeg
},
622 {data39
, sizeof(data39
), mimeImageTiff
, mimeImageTiff
},
623 {data40
, sizeof(data40
), mimeTextHtml
, mimeImageTiff
},
624 {data41
, sizeof(data41
), mimeTextPlain
, mimeTextPlain
, mimeImageTiff
},
625 {data42
, sizeof(data42
), mimeTextPlain
, mimeTextPlain
},
626 {data43
, sizeof(data43
), mimeAppOctetStream
, mimeImagePjpeg
},
627 {data44
, sizeof(data44
), mimeVideoAvi
, mimeVideoAvi
},
628 {data45
, sizeof(data45
), mimeTextPlain
, mimeTextPlain
},
629 {data46
, sizeof(data46
), mimeTextPlain
, mimeTextPlain
},
630 {data47
, sizeof(data47
), mimeTextPlain
, mimeTextPlain
},
631 {data48
, sizeof(data48
), mimeTextHtml
, mimeVideoAvi
},
632 {data49
, sizeof(data49
), mimeVideoAvi
, mimeVideoAvi
},
633 {data50
, sizeof(data50
), mimeVideoMpeg
, mimeVideoMpeg
},
634 {data51
, sizeof(data51
), mimeVideoMpeg
, mimeVideoMpeg
},
635 {data52
, sizeof(data52
), mimeAppOctetStream
, mimeImagePjpeg
},
636 {data53
, sizeof(data53
), mimeAppOctetStream
, mimeImagePjpeg
},
637 {data54
, sizeof(data54
), mimeTextHtml
, mimeVideoMpeg
},
638 {data55
, sizeof(data55
), mimeAppXGzip
, mimeAppXGzip
},
639 {data56
, sizeof(data56
), mimeTextPlain
, mimeTextPlain
},
640 {data57
, sizeof(data57
), mimeTextHtml
, mimeAppXGzip
},
641 {data58
, sizeof(data58
), mimeAppOctetStream
, mimeImagePjpeg
},
642 {data59
, sizeof(data59
), mimeAppXZip
, mimeAppXZip
},
643 {data60
, sizeof(data60
), mimeTextPlain
, mimeTextPlain
},
644 {data61
, sizeof(data61
), mimeTextHtml
, mimeAppXZip
},
645 {data62
, sizeof(data62
), mimeAppJava
, mimeAppJava
},
646 {data63
, sizeof(data63
), mimeTextPlain
, mimeTextPlain
},
647 {data64
, sizeof(data64
), mimeTextHtml
, mimeAppJava
},
648 {data65
, sizeof(data65
), mimeAppPdf
, mimeAppPdf
},
649 {data66
, sizeof(data66
), mimeTextPlain
, mimeTextPlain
},
650 {data67
, sizeof(data67
), mimeTextHtml
, mimeAppPdf
},
651 {data68
, sizeof(data68
), mimeAppXMSDownload
, mimeAppXMSDownload
},
652 {data69
, sizeof(data69
), mimeTextPlain
, mimeTextPlain
},
653 {data70
, sizeof(data70
), mimeTextHtml
, mimeAppXMSDownload
},
654 {data71
, sizeof(data71
), mimeTextRichtext
, mimeTextRichtext
},
655 {data72
, sizeof(data72
), mimeTextPlain
, mimeTextPlain
},
656 {data73
, sizeof(data73
), mimeTextPlain
, mimeTextPlain
},
657 {data74
, sizeof(data74
), mimeTextHtml
, mimeTextRichtext
},
658 {data75
, sizeof(data75
), mimeAudioWav
, mimeAudioWav
},
659 {data76
, sizeof(data76
), mimeTextPlain
, mimeTextPlain
},
660 {data77
, sizeof(data77
), mimeTextPlain
, mimeTextPlain
},
661 {data78
, sizeof(data78
), mimeTextHtml
, mimeTextPlain
},
662 {data79
, sizeof(data79
), mimeAppPostscript
, mimeAppPostscript
},
663 {data80
, sizeof(data80
), mimeTextPlain
, mimeTextPlain
},
664 {data81
, sizeof(data81
), mimeTextHtml
, mimeAppPostscript
},
665 {data82
, sizeof(data82
), mimeAudioBasic
, mimeAudioBasic
},
666 {data83
, sizeof(data83
), mimeTextPlain
, mimeTextPlain
},
667 {data84
, sizeof(data84
), mimeTextHtml
, mimeAudioBasic
},
668 {data85
, sizeof(data85
), mimeTextPlain
, mimeTextPlain
},
669 {data86
, sizeof(data86
), mimeImageTiff
, mimeImageTiff
, mimeTextPlain
},
670 {data87
, sizeof(data87
), mimeTextPlain
, mimeTextPlain
},
671 {data88
, sizeof(data88
), mimeTextHtml
, mimeTextPlain
},
672 {data89
, sizeof(data89
), mimeTextHtml
, mimeTextPlain
},
673 {data90
, sizeof(data90
), mimeTextHtml
, mimeTextPlain
},
674 {data91
, sizeof(data91
), mimeTextXml
, mimeTextPlain
},
675 {data92
, sizeof(data92
), mimeTextXml
, mimeTextPlain
},
676 {data93
, sizeof(data93
), mimeTextXml
, mimeTextPlain
},
677 {data94
, sizeof(data94
), mimeTextHtml
, mimeTextPlain
},
678 {data95
, sizeof(data95
), mimeTextXml
, mimeTextRichtext
},
679 {data96
, sizeof(data96
), mimeTextPlain
, mimeTextPlain
}
682 static void test_FindMimeFromData(void)
689 for(i
=0; i
<sizeof(mime_tests
)/sizeof(mime_tests
[0]); i
++) {
690 mime
= (LPWSTR
)0xf0f0f0f0;
691 hres
= pFindMimeFromData(NULL
, mime_tests
[i
].url
, NULL
, 0, NULL
, 0, &mime
, 0);
692 if(mime_tests
[i
].mime
) {
693 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
694 ok(!lstrcmpW(mime
, mime_tests
[i
].mime
), "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
697 ok(hres
== E_FAIL
|| hres
== mime_tests
[i
].hres
,
698 "[%d] FindMimeFromData failed: %08x, expected %08x\n",
699 i
, hres
, mime_tests
[i
].hres
);
700 ok(mime
== (LPWSTR
)0xf0f0f0f0, "[%d] mime != 0xf0f0f0f0\n", i
);
703 mime
= (LPWSTR
)0xf0f0f0f0;
704 hres
= pFindMimeFromData(NULL
, mime_tests
[i
].url
, NULL
, 0, mimeTextPlain
, 0, &mime
, 0);
705 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
706 ok(!lstrcmpW(mime
, mimeTextPlain
), "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
709 mime
= (LPWSTR
)0xf0f0f0f0;
710 hres
= pFindMimeFromData(NULL
, mime_tests
[i
].url
, NULL
, 0, mimeAppOctetStream
, 0, &mime
, 0);
711 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
712 ok(!lstrcmpW(mime
, mimeAppOctetStream
), "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
716 for(i
=0; i
< sizeof(mime_tests2
)/sizeof(mime_tests2
[0]); i
++) {
717 hres
= pFindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
719 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
720 b
= !lstrcmpW(mime
, mime_tests2
[i
].mime
);
721 ok(b
|| broken(mime_tests2
[i
].broken_mime
&& !lstrcmpW(mime
, mime_tests2
[i
].broken_mime
)),
722 "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
727 hres
= pFindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
728 mimeAppOctetStream
, 0, &mime
, 0);
729 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
730 ok(!lstrcmpW(mime
, mime_tests2
[i
].mime
) || broken(mime_tests2
[i
].broken_mime
731 && !lstrcmpW(mime
, mime_tests2
[i
].broken_mime
)),
732 "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
735 hres
= pFindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
736 mimeTextPlain
, 0, &mime
, 0);
737 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
738 ok(!lstrcmpW(mime
, mime_tests2
[i
].mime
) || broken(mime_tests2
[i
].broken_mime
739 && !lstrcmpW(mime
, mime_tests2
[i
].broken_mime
)),
740 "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
743 hres
= pFindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
744 mimeTextHtml
, 0, &mime
, 0);
745 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
746 if(!lstrcmpW(mimeAppOctetStream
, mime_tests2
[i
].mime
)
747 || !lstrcmpW(mimeTextPlain
, mime_tests2
[i
].mime
) || i
==92)
748 ok(!lstrcmpW(mime
, mimeTextHtml
), "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
750 ok(!lstrcmpW(mime
, mime_tests2
[i
].mime
), "[%d] wrong mime: %s\n", i
, wine_dbgstr_w(mime
));
753 hres
= pFindMimeFromData(NULL
, NULL
, mime_tests2
[i
].data
, mime_tests2
[i
].size
,
754 mimeImagePjpeg
, 0, &mime
, 0);
755 ok(hres
== S_OK
, "[%d] FindMimeFromData failed: %08x\n", i
, hres
);
756 ok(!lstrcmpW(mime
, mime_tests2
[i
].mime_pjpeg
) || broken(!lstrcmpW(mime
, mime_tests2
[i
].mime
)),
757 "[%d] wrong mime, got %s\n", i
, wine_dbgstr_w(mime
));
761 hres
= pFindMimeFromData(NULL
, url1
, data1
, sizeof(data1
), NULL
, 0, &mime
, 0);
762 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
763 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
766 hres
= pFindMimeFromData(NULL
, url1
, data1
, sizeof(data1
), mimeAppOctetStream
, 0, &mime
, 0);
767 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
768 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
771 hres
= pFindMimeFromData(NULL
, url4
, data1
, sizeof(data1
), mimeAppOctetStream
, 0, &mime
, 0);
772 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
773 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
776 hres
= pFindMimeFromData(NULL
, url1
, NULL
, 0, NULL
, 0, &mime
, 0);
777 ok(hres
== S_OK
, "FindMimeFromData failed: %08x, expected S_OK\n", hres
);
778 ok(!lstrcmpW(mime
, mimeTextHtml
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
781 hres
= pFindMimeFromData(NULL
, url1
, NULL
, sizeof(data1
), NULL
, 0, &mime
, 0);
782 ok(hres
== S_OK
, "FindMimeFromData failed: %08x, expected S_OK\n", hres
);
783 ok(!lstrcmpW(mime
, mimeTextHtml
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
786 hres
= pFindMimeFromData(NULL
, url1
, 0, 0, NULL
, 0, &mime
, 0);
787 ok(hres
== S_OK
, "FindMimeFromData failed: %08x, expected S_OK\n", hres
);
788 ok(!lstrcmpW(mime
, mimeTextHtml
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
791 hres
= pFindMimeFromData(NULL
, url1
, 0, sizeof(data1
), NULL
, 0, &mime
, 0);
792 ok(hres
== S_OK
, "FindMimeFromData failed: %08x, expected S_OK\n", hres
);
793 ok(!lstrcmpW(mime
, mimeTextHtml
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
796 hres
= pFindMimeFromData(NULL
, url1
, data1
, sizeof(data1
), NULL
, 0, &mime
, 0);
797 ok(hres
== S_OK
, "FindMimeFromData failed: %08x, expected S_OK\n", hres
);
798 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
801 hres
= pFindMimeFromData(NULL
, NULL
, NULL
, 0, NULL
, 0, &mime
, 0);
802 ok(hres
== E_INVALIDARG
, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres
);
804 hres
= pFindMimeFromData(NULL
, NULL
, NULL
, 0, mimeTextPlain
, 0, &mime
, 0);
805 ok(hres
== E_INVALIDARG
, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres
);
807 hres
= pFindMimeFromData(NULL
, NULL
, data1
, 0, NULL
, 0, &mime
, 0);
808 ok(hres
== E_FAIL
, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres
);
810 hres
= pFindMimeFromData(NULL
, url1
, data1
, 0, NULL
, 0, &mime
, 0);
811 ok(hres
== E_FAIL
, "FindMimeFromData failed: %08x, expected E_FAIL\n", hres
);
813 hres
= pFindMimeFromData(NULL
, NULL
, data1
, 0, mimeTextPlain
, 0, &mime
, 0);
814 ok(hres
== S_OK
, "FindMimeFromData failed: %08x\n", hres
);
815 ok(!lstrcmpW(mime
, mimeTextPlain
), "wrong mime: %s\n", wine_dbgstr_w(mime
));
818 hres
= pFindMimeFromData(NULL
, NULL
, data1
, 0, mimeTextPlain
, 0, NULL
, 0);
819 ok(hres
== E_INVALIDARG
, "FindMimeFromData failed: %08x, expected E_INVALIDARG\n", hres
);
822 static void register_protocols(void)
824 IInternetSession
*session
;
825 IClassFactory
*factory
;
828 static const WCHAR wszAbout
[] = {'a','b','o','u','t',0};
830 hres
= pCoInternetGetSession(0, &session
, 0);
831 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
835 hres
= CoGetClassObject(&CLSID_AboutProtocol
, CLSCTX_INPROC_SERVER
, NULL
,
836 &IID_IClassFactory
, (void**)&factory
);
837 ok(hres
== S_OK
, "Could not get AboutProtocol factory: %08x\n", hres
);
841 IInternetSession_RegisterNameSpace(session
, factory
, &CLSID_AboutProtocol
,
842 wszAbout
, 0, NULL
, 0);
843 IClassFactory_Release(factory
);
845 IInternetSession_Release(session
);
848 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
849 REFIID riid
, void **ppv
)
851 ok(0, "unexpected call\n");
852 return E_NOINTERFACE
;
855 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
860 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
865 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
866 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
867 DWORD
*pcchResult
, DWORD dwReserved
)
869 CHECK_EXPECT2(ParseUrl
);
871 if(ParseAction
== PARSE_SECURITY_URL
) {
873 *pcchResult
= sizeof(url1
)/sizeof(WCHAR
);
875 if(cchResult
<sizeof(url1
)/sizeof(WCHAR
))
878 memcpy(pwzResult
, url1
, sizeof(url1
));
885 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
886 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
887 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
889 ok(0, "unexpected call\n");
893 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
894 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
896 ok(0, "unexpected call\n");
900 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
901 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
902 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
904 ok(0, "unexpected call\n");
908 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
909 InternetProtocolInfo_QueryInterface
,
910 InternetProtocolInfo_AddRef
,
911 InternetProtocolInfo_Release
,
912 InternetProtocolInfo_ParseUrl
,
913 InternetProtocolInfo_CombineUrl
,
914 InternetProtocolInfo_CompareUrl
,
915 InternetProtocolInfo_QueryInfo
918 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
920 static HRESULT qiret
;
921 static IClassFactory
*expect_cf
;
923 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
925 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
926 CHECK_EXPECT2(QI_IInternetProtocolInfo
);
927 ok(iface
== expect_cf
, "unexpected iface\n");
928 *ppv
= &protocol_info
;
932 ok(0, "unexpected call\n");
933 return E_NOINTERFACE
;
936 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
941 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
946 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
947 REFIID riid
, void **ppv
)
949 ok(0, "unexpected call\n");
953 static HRESULT WINAPI
ProtocolCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
954 REFIID riid
, void **ppv
)
956 CHECK_EXPECT(CreateInstance
);
958 ok(iface
== expect_cf
, "unexpected iface\n");
959 ok(pOuter
== NULL
, "pOuter = %p\n", pOuter
);
960 ok(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
), "unexpected riid\n");
961 ok(ppv
!= NULL
, "ppv == NULL\n");
963 *ppv
= &protocol_info
;
967 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
969 ok(0, "unexpected call\n");
973 static const IClassFactoryVtbl ClassFactoryVtbl
= {
974 ClassFactory_QueryInterface
,
976 ClassFactory_Release
,
977 ClassFactory_CreateInstance
,
978 ClassFactory_LockServer
981 static const IClassFactoryVtbl ProtocolCFVtbl
= {
982 ClassFactory_QueryInterface
,
984 ClassFactory_Release
,
985 ProtocolCF_CreateInstance
,
986 ClassFactory_LockServer
989 static IClassFactory test_protocol_cf
= { &ProtocolCFVtbl
};
990 static IClassFactory test_protocol_cf2
= { &ProtocolCFVtbl
};
991 static IClassFactory test_cf
= { &ClassFactoryVtbl
};
993 static void test_NameSpace(void)
995 IInternetSession
*session
;
1001 static const WCHAR wszTest
[] = {'t','e','s','t',0};
1003 hres
= pCoInternetGetSession(0, &session
, 0);
1004 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
1008 hres
= IInternetSession_RegisterNameSpace(session
, NULL
, &IID_NULL
,
1009 wszTest
, 0, NULL
, 0);
1010 ok(hres
== E_INVALIDARG
, "RegisterNameSpace failed: %08x\n", hres
);
1012 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1014 ok(hres
== E_INVALIDARG
, "RegisterNameSpace failed: %08x\n", hres
);
1016 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1017 wszTest
, 0, NULL
, 0);
1018 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1020 qiret
= E_NOINTERFACE
;
1021 expect_cf
= &test_protocol_cf
;
1022 SET_EXPECT(QI_IInternetProtocolInfo
);
1023 SET_EXPECT(CreateInstance
);
1024 SET_EXPECT(ParseUrl
);
1026 hres
= pCoInternetParseUrl(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(CreateInstance
);
1032 CHECK_CALLED(ParseUrl
);
1035 SET_EXPECT(QI_IInternetProtocolInfo
);
1036 SET_EXPECT(ParseUrl
);
1038 hres
= pCoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1040 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1042 CHECK_CALLED(QI_IInternetProtocolInfo
);
1043 CHECK_CALLED(ParseUrl
);
1045 SET_EXPECT(QI_IInternetProtocolInfo
);
1046 SET_EXPECT(ParseUrl
);
1048 hres
= pCoInternetParseUrl(url8
, PARSE_SECURITY_URL
, 0, buf
,
1049 sizeof(buf
)/sizeof(WCHAR
), &size
, 0);
1050 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1051 ok(size
== sizeof(url1
)/sizeof(WCHAR
), "Size = %d\n", size
);
1052 if(size
== sizeof(url1
)/sizeof(WCHAR
))
1053 ok(!memcmp(buf
, url1
, sizeof(url1
)), "Encoded url = %s\n", wine_dbgstr_w(buf
));
1055 CHECK_CALLED(QI_IInternetProtocolInfo
);
1056 CHECK_CALLED(ParseUrl
);
1058 SET_EXPECT(QI_IInternetProtocolInfo
);
1059 SET_EXPECT(ParseUrl
);
1061 if (pCoInternetGetSecurityUrl
) {
1062 hres
= pCoInternetGetSecurityUrl(url8
, &sec_url
, PSU_SECURITY_URL_ONLY
, 0);
1063 ok(hres
== S_OK
, "CoInternetGetSecurityUrl failed: %08x\n", hres
);
1065 ok(lstrlenW(sec_url
)>sizeof(wszFile
)/sizeof(WCHAR
) &&
1066 !memcmp(sec_url
, wszFile
, sizeof(wszFile
)-sizeof(WCHAR
)),
1067 "Encoded url = %s\n", wine_dbgstr_w(sec_url
));
1068 CoTaskMemFree(sec_url
);
1071 CHECK_CALLED(QI_IInternetProtocolInfo
);
1072 CHECK_CALLED(ParseUrl
);
1075 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1076 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1078 hres
= pCoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1080 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1082 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf2
, &IID_NULL
,
1083 wszTest
, 0, NULL
, 0);
1084 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1086 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1087 wszTest
, 0, NULL
, 0);
1088 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1090 hres
= IInternetSession_RegisterNameSpace(session
, &test_protocol_cf
, &IID_NULL
,
1091 wszTest
, 0, NULL
, 0);
1092 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1094 SET_EXPECT(QI_IInternetProtocolInfo
);
1095 SET_EXPECT(ParseUrl
);
1097 hres
= pCoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1099 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1101 CHECK_CALLED(QI_IInternetProtocolInfo
);
1102 CHECK_CALLED(ParseUrl
);
1104 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1105 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1107 SET_EXPECT(QI_IInternetProtocolInfo
);
1108 SET_EXPECT(ParseUrl
);
1110 hres
= pCoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1112 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1114 CHECK_CALLED(QI_IInternetProtocolInfo
);
1115 CHECK_CALLED(ParseUrl
);
1117 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1118 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1120 expect_cf
= &test_protocol_cf2
;
1121 SET_EXPECT(QI_IInternetProtocolInfo
);
1122 SET_EXPECT(ParseUrl
);
1124 hres
= pCoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1126 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1128 CHECK_CALLED(QI_IInternetProtocolInfo
);
1129 CHECK_CALLED(ParseUrl
);
1131 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1132 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1133 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, wszTest
);
1134 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1135 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf
, NULL
);
1136 ok(hres
== E_INVALIDARG
, "UnregisterNameSpace failed: %08x\n", hres
);
1137 hres
= IInternetSession_UnregisterNameSpace(session
, NULL
, wszTest
);
1138 ok(hres
== E_INVALIDARG
, "UnregisterNameSpace failed: %08x\n", hres
);
1140 hres
= IInternetSession_UnregisterNameSpace(session
, &test_protocol_cf2
, wszTest
);
1141 ok(hres
== S_OK
, "UnregisterNameSpace failed: %08x\n", hres
);
1143 hres
= pCoInternetParseUrl(url8
, PARSE_ENCODE
, 0, buf
, sizeof(buf
)/sizeof(WCHAR
),
1145 ok(hres
== S_OK
, "CoInternetParseUrl failed: %08x\n", hres
);
1147 IInternetSession_Release(session
);
1150 static void test_MimeFilter(void)
1152 IInternetSession
*session
;
1155 static const WCHAR mimeW
[] = {'t','e','s','t','/','m','i','m','e',0};
1157 hres
= pCoInternetGetSession(0, &session
, 0);
1158 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
1162 hres
= IInternetSession_RegisterMimeFilter(session
, &test_cf
, &IID_NULL
, mimeW
);
1163 ok(hres
== S_OK
, "RegisterMimeFilter failed: %08x\n", hres
);
1165 hres
= IInternetSession_UnregisterMimeFilter(session
, &test_cf
, mimeW
);
1166 ok(hres
== S_OK
, "UnregisterMimeFilter failed: %08x\n", hres
);
1168 hres
= IInternetSession_UnregisterMimeFilter(session
, &test_cf
, mimeW
);
1169 ok(hres
== S_OK
, "UnregisterMimeFilter failed: %08x\n", hres
);
1171 hres
= IInternetSession_UnregisterMimeFilter(session
, (void*)0xdeadbeef, mimeW
);
1172 ok(hres
== S_OK
, "UnregisterMimeFilter failed: %08x\n", hres
);
1174 IInternetSession_Release(session
);
1177 static ULONG WINAPI
unk_Release(IUnknown
*iface
)
1179 CHECK_EXPECT(unk_Release
);
1183 static const IUnknownVtbl unk_vtbl
= {
1189 static void test_ReleaseBindInfo(void)
1192 IUnknown unk
= { &unk_vtbl
};
1194 pReleaseBindInfo(NULL
); /* shouldn't crash */
1196 memset(&bi
, 0, sizeof(bi
));
1197 bi
.cbSize
= sizeof(BINDINFO
);
1199 SET_EXPECT(unk_Release
);
1200 pReleaseBindInfo(&bi
);
1201 ok(bi
.cbSize
== sizeof(BINDINFO
), "bi.cbSize=%d\n", bi
.cbSize
);
1202 ok(bi
.pUnk
== NULL
, "bi.pUnk=%p, expected NULL\n", bi
.pUnk
);
1203 CHECK_CALLED(unk_Release
);
1205 memset(&bi
, 0, sizeof(bi
));
1206 bi
.cbSize
= offsetof(BINDINFO
, pUnk
);
1208 pReleaseBindInfo(&bi
);
1209 ok(bi
.cbSize
== offsetof(BINDINFO
, pUnk
), "bi.cbSize=%d\n", bi
.cbSize
);
1210 ok(bi
.pUnk
== &unk
, "bi.pUnk=%p, expected %p\n", bi
.pUnk
, &unk
);
1212 memset(&bi
, 0, sizeof(bi
));
1214 pReleaseBindInfo(&bi
);
1215 ok(!bi
.cbSize
, "bi.cbSize=%d, expected 0\n", bi
.cbSize
);
1216 ok(bi
.pUnk
== &unk
, "bi.pUnk=%p, expected %p\n", bi
.pUnk
, &unk
);
1219 static void test_CopyStgMedium(void)
1227 static WCHAR fileW
[] = {'f','i','l','e',0};
1229 memset(&src
, 0xf0, sizeof(src
));
1230 memset(&dst
, 0xe0, sizeof(dst
));
1231 memset(&empty
, 0xf0, sizeof(empty
));
1232 src
.tymed
= TYMED_NULL
;
1233 src
.pUnkForRelease
= NULL
;
1234 hres
= pCopyStgMedium(&src
, &dst
);
1235 ok(hres
== S_OK
, "CopyStgMedium failed: %08x\n", hres
);
1236 ok(dst
.tymed
== TYMED_NULL
, "tymed=%d\n", dst
.tymed
);
1237 ok(dst
.u
.hGlobal
== empty
, "u=%p\n", dst
.u
.hGlobal
);
1238 ok(!dst
.pUnkForRelease
, "pUnkForRelease=%p, expected NULL\n", dst
.pUnkForRelease
);
1240 memset(&dst
, 0xe0, sizeof(dst
));
1241 src
.tymed
= TYMED_ISTREAM
;
1243 src
.pUnkForRelease
= NULL
;
1244 hres
= pCopyStgMedium(&src
, &dst
);
1245 ok(hres
== S_OK
, "CopyStgMedium failed: %08x\n", hres
);
1246 ok(dst
.tymed
== TYMED_ISTREAM
, "tymed=%d\n", dst
.tymed
);
1247 ok(!dst
.u
.pstm
, "pstm=%p\n", dst
.u
.pstm
);
1248 ok(!dst
.pUnkForRelease
, "pUnkForRelease=%p, expected NULL\n", dst
.pUnkForRelease
);
1250 memset(&dst
, 0xe0, sizeof(dst
));
1251 src
.tymed
= TYMED_FILE
;
1252 src
.u
.lpszFileName
= fileW
;
1253 src
.pUnkForRelease
= NULL
;
1254 hres
= pCopyStgMedium(&src
, &dst
);
1255 ok(hres
== S_OK
, "CopyStgMedium failed: %08x\n", hres
);
1256 ok(dst
.tymed
== TYMED_FILE
, "tymed=%d\n", dst
.tymed
);
1257 ok(dst
.u
.lpszFileName
&& dst
.u
.lpszFileName
!= fileW
, "lpszFileName=%p\n", dst
.u
.lpszFileName
);
1258 ok(!lstrcmpW(dst
.u
.lpszFileName
, fileW
), "wrong file name\n");
1259 ok(!dst
.pUnkForRelease
, "pUnkForRelease=%p, expected NULL\n", dst
.pUnkForRelease
);
1260 ReleaseStgMedium(&dst
);
1263 hg
= GlobalAlloc(GMEM_MOVEABLE
, 10);
1264 ptr1
= GlobalLock(hg
);
1265 memset(ptr1
, 0xfa, 10);
1266 memset(&dst
, 0xe0, sizeof(dst
));
1267 src
.tymed
= TYMED_HGLOBAL
;
1269 hres
= pCopyStgMedium(&src
, &dst
);
1270 ok(hres
== S_OK
, "CopyStgMedium failed: %08x\n", hres
);
1271 ok(dst
.tymed
== TYMED_HGLOBAL
, "tymed=%d\n", dst
.tymed
);
1272 ok(dst
.u
.hGlobal
!= hg
, "got %p, %p\n", dst
.u
.hGlobal
, hg
);
1273 size
= GlobalSize(dst
.u
.hGlobal
);
1274 ok(size
== 10, "got size %d\n", size
);
1275 /* compare contents */
1276 ptr2
= GlobalLock(dst
.u
.hGlobal
);
1277 ok(!memcmp(ptr1
, ptr2
, 10), "got wrong data\n");
1280 ok(GlobalFlags(dst
.u
.hGlobal
) == 0, "got 0x%08x\n", GlobalFlags(dst
.u
.hGlobal
));
1282 ReleaseStgMedium(&dst
);
1284 memset(&dst
, 0xe0, sizeof(dst
));
1285 src
.tymed
= TYMED_HGLOBAL
;
1286 src
.u
.hGlobal
= NULL
;
1287 hres
= pCopyStgMedium(&src
, &dst
);
1288 ok(hres
== S_OK
, "CopyStgMedium failed: %08x\n", hres
);
1289 ok(dst
.u
.hGlobal
== NULL
, "got %p\n", dst
.u
.hGlobal
);
1291 hres
= pCopyStgMedium(&src
, NULL
);
1292 ok(hres
== E_POINTER
, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres
);
1293 hres
= pCopyStgMedium(NULL
, &dst
);
1294 ok(hres
== E_POINTER
, "CopyStgMedium failed: %08x, expected E_POINTER\n", hres
);
1297 static void test_CopyBindInfo(void)
1299 BINDINFO src
[2], dest
[2];
1300 SECURITY_DESCRIPTOR sec_desc
;
1304 hres
= pCopyBindInfo(NULL
, NULL
);
1305 ok(hres
== E_POINTER
, "CopyBindInfo returned %08x, expected E_POINTER\n", hres
);
1307 memset(src
, 0, sizeof(BINDINFO
[2]));
1308 memset(dest
, 0xde, sizeof(BINDINFO
[2]));
1309 hres
= pCopyBindInfo(src
, dest
);
1310 ok(hres
== E_INVALIDARG
, "CopyBindInfo retuned: %08x, expected E_INVALIDARG\n", hres
);
1312 memset(src
, 0, sizeof(BINDINFO
[2]));
1313 memset(dest
, 0xde, sizeof(BINDINFO
[2]));
1314 src
[0].cbSize
= sizeof(BINDINFO
);
1316 hres
= pCopyBindInfo(src
, dest
);
1317 ok(hres
== E_INVALIDARG
, "CopyBindInfo retuned: %08x, expected E_INVALIDARG\n", hres
);
1319 memset(src
, 0, sizeof(BINDINFO
[2]));
1320 memset(dest
, 0xde, sizeof(BINDINFO
[2]));
1322 dest
[0].cbSize
= sizeof(BINDINFO
)+sizeof(DWORD
);
1323 hres
= pCopyBindInfo(src
, dest
);
1324 ok(hres
== S_OK
, "CopyBindInfo failed: %08x\n", hres
);
1325 ok(dest
[0].cbSize
== sizeof(BINDINFO
)+sizeof(DWORD
), "incorrect cbSize: %d\n", dest
[0].cbSize
);
1326 for(i
=1; i
<dest
[0].cbSize
/sizeof(int); i
++)
1327 ok(((int*)dest
)[i
] == 0, "unset values should be set to 0, got %d on %d\n", ((int*)dest
)[i
], i
);
1329 memset(src
, 0, sizeof(BINDINFO
[2]));
1330 memset(dest
, 0xde, sizeof(BINDINFO
[2]));
1331 src
[0].cbSize
= sizeof(BINDINFO
)+2*sizeof(DWORD
);
1332 dest
[0].cbSize
= sizeof(BINDINFO
)+sizeof(DWORD
);
1333 hres
= pCopyBindInfo(src
, dest
);
1334 ok(hres
== S_OK
, "CopyBindInfo failed: %08x\n", hres
);
1335 ok(dest
[1].cbSize
== src
[1].cbSize
, "additional data should be copied\n");
1336 ok(dest
[1].szExtraInfo
!= src
[1].szExtraInfo
,
1337 "data not fitting in destination buffer should not be copied\n");
1339 memset(src
, 0xf0, sizeof(BINDINFO
[2]));
1340 memset(dest
, 0xde, sizeof(BINDINFO
[2]));
1341 src
[0].cbSize
= sizeof(BINDINFO
);
1342 src
[0].szExtraInfo
= CoTaskMemAlloc(sizeof(WCHAR
));
1343 src
[0].szExtraInfo
[0] = 0;
1344 src
[0].szCustomVerb
= NULL
;
1346 src
[0].stgmedData
.tymed
= TYMED_NULL
;
1347 src
[0].stgmedData
.pUnkForRelease
= NULL
;
1348 dest
[0].cbSize
= sizeof(BINDINFO
);
1349 hres
= pCopyBindInfo(src
, dest
);
1350 ok(hres
== S_OK
, "CopyBindInfo failed: %08x\n", hres
);
1352 ok(dest
[0].cbSize
== sizeof(BINDINFO
), "incorrect cbSize: %d\n", dest
[0].cbSize
);
1353 ok(dest
[0].szExtraInfo
&& !dest
[0].szExtraInfo
[0] && dest
[0].szExtraInfo
!=src
[0].szExtraInfo
,
1354 "incorrect szExtraInfo: (%p!=%p) %d\n", dest
[0].szExtraInfo
,
1355 src
[0].szExtraInfo
, dest
[0].szExtraInfo
[0]);
1356 ok(!memcmp(&dest
[0].stgmedData
, &src
[0].stgmedData
, sizeof(STGMEDIUM
)),
1357 "incorrect stgmedData value\n");
1358 ok(src
[0].grfBindInfoF
== dest
[0].grfBindInfoF
, "grfBindInfoF = %x, expected %x\n",
1359 dest
[0].grfBindInfoF
, src
[0].grfBindInfoF
);
1360 ok(src
[0].dwBindVerb
== dest
[0].dwBindVerb
, "dwBindVerb = %x, expected %x\n",
1361 dest
[0].dwBindVerb
, src
[0].dwBindVerb
);
1362 ok(!dest
[0].szCustomVerb
, "szCustmoVerb != NULL\n");
1363 ok(src
[0].cbstgmedData
== dest
[0].cbstgmedData
, "cbstgmedData = %x, expected %x\n",
1364 dest
[0].cbstgmedData
, src
[0].cbstgmedData
);
1365 ok(src
[0].dwOptions
== dest
[0].dwOptions
, "dwOptions = %x, expected %x\n",
1366 dest
[0].dwOptions
, src
[0].dwOptions
);
1367 ok(src
[0].dwOptionsFlags
== dest
[0].dwOptionsFlags
, "dwOptionsFlags = %x, expected %x\n",
1368 dest
[0].dwOptionsFlags
, src
[0].dwOptionsFlags
);
1369 ok(src
[0].dwCodePage
== dest
[0].dwCodePage
, "dwCodePage = %x, expected %x\n",
1370 dest
[0].dwCodePage
, src
[0].dwCodePage
);
1371 ok(!dest
[0].securityAttributes
.nLength
,
1372 "unexpected securityAttributes.nLength value: %d\n",
1373 dest
[0].securityAttributes
.nLength
);
1374 ok(!dest
[0].securityAttributes
.lpSecurityDescriptor
,
1375 "unexpected securityAttributes.lpSecurityDescriptor value: %p\n",
1376 dest
[0].securityAttributes
.lpSecurityDescriptor
);
1377 ok(!dest
[0].securityAttributes
.bInheritHandle
,
1378 "unexpected securityAttributes.bInheritHandle value: %d\n",
1379 dest
[0].securityAttributes
.bInheritHandle
);
1380 ok(!memcmp(&dest
[0].iid
, &src
[0].iid
, sizeof(IID
)),
1381 "incorrect iid value\n");
1382 ok(!dest
[0].pUnk
, "pUnk != NULL\n");
1383 ok(src
[0].dwReserved
== dest
[0].dwReserved
, "dwReserved = %x, expected %x\n",
1384 dest
[0].dwReserved
, src
[0].dwReserved
);
1386 CoTaskMemFree(src
[0].szExtraInfo
);
1387 CoTaskMemFree(dest
[0].szExtraInfo
);
1389 src
[0].szExtraInfo
= NULL
;
1390 src
[0].securityAttributes
.nLength
= sizeof(SECURITY_ATTRIBUTES
);
1391 ok(InitializeSecurityDescriptor(&sec_desc
, SECURITY_DESCRIPTOR_REVISION
),
1392 "InitializeSecurityDescriptor failed\n");
1393 src
[0].securityAttributes
.lpSecurityDescriptor
= (void*)&sec_desc
;
1394 src
[0].securityAttributes
.bInheritHandle
= TRUE
;
1395 hres
= pCopyBindInfo(src
, dest
);
1396 ok(hres
== S_OK
, "CopyBindInfo failed: %08x\n", hres
);
1397 ok(!dest
[0].securityAttributes
.nLength
,
1398 "unexpected securityAttributes.nLength value: %d\n",
1399 dest
[0].securityAttributes
.nLength
);
1400 ok(!dest
[0].securityAttributes
.lpSecurityDescriptor
,
1401 "unexpected securityAttributes.lpSecurityDescriptor value: %p\n",
1402 dest
[0].securityAttributes
.lpSecurityDescriptor
);
1403 ok(!dest
[0].securityAttributes
.bInheritHandle
,
1404 "unexpected securityAttributes.bInheritHandle value: %d\n",
1405 dest
[0].securityAttributes
.bInheritHandle
);
1408 static void test_UrlMkGetSessionOption(void)
1410 DWORD encoding
, size
;
1413 size
= encoding
= 0xdeadbeef;
1414 hres
= pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1415 sizeof(encoding
), &size
, 0);
1416 ok(hres
== S_OK
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1417 ok(encoding
!= 0xdeadbeef, "encoding not changed\n");
1418 ok(size
== sizeof(encoding
), "size=%d\n", size
);
1420 size
= encoding
= 0xdeadbeef;
1421 hres
= pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1422 sizeof(encoding
)+1, &size
, 0);
1423 ok(hres
== S_OK
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1424 ok(encoding
!= 0xdeadbeef, "encoding not changed\n");
1425 ok(size
== sizeof(encoding
), "size=%d\n", size
);
1427 size
= encoding
= 0xdeadbeef;
1428 hres
= pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1429 sizeof(encoding
)-1, &size
, 0);
1430 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1431 ok(encoding
== 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding
);
1432 ok(size
== 0xdeadbeef, "size=%d\n", size
);
1434 size
= encoding
= 0xdeadbeef;
1435 hres
= pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, NULL
,
1436 sizeof(encoding
)-1, &size
, 0);
1437 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1438 ok(encoding
== 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding
);
1439 ok(size
== 0xdeadbeef, "size=%d\n", size
);
1441 encoding
= 0xdeadbeef;
1442 hres
= pUrlMkGetSessionOption(URLMON_OPTION_URL_ENCODING
, &encoding
,
1443 sizeof(encoding
)-1, NULL
, 0);
1444 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1445 ok(encoding
== 0xdeadbeef, "encoding = %08x, exepcted 0xdeadbeef\n", encoding
);
1448 static void test_user_agent(void)
1450 static const CHAR expected
[] = "Mozilla/4.0 (compatible; MSIE ";
1451 static char test_str
[] = "test";
1452 static char test2_str
[] = "test\0test";
1458 hres
= pObtainUserAgentString(0, NULL
, NULL
);
1459 ok(hres
== E_INVALIDARG
, "ObtainUserAgentString failed: %08x\n", hres
);
1462 hres
= pObtainUserAgentString(0, NULL
, &size
);
1463 ok(hres
== E_INVALIDARG
, "ObtainUserAgentString failed: %08x\n", hres
);
1464 ok(size
== 100, "size=%d, expected %d\n", size
, 100);
1467 hres
= pObtainUserAgentString(0, str
, &size
);
1468 ok(hres
== E_OUTOFMEMORY
, "ObtainUserAgentString failed: %08x\n", hres
);
1469 ok(size
> 0, "size=%d, expected non-zero\n", size
);
1473 hres
= pObtainUserAgentString(0, str
, &size
);
1474 ok(hres
== E_OUTOFMEMORY
, "ObtainUserAgentString failed: %08x\n", hres
);
1475 ok(size
> 0, "size=%d, expected non-zero\n", size
);
1476 ok(str
[0] == 'a', "str[0]=%c, expected 'a'\n", str
[0]);
1479 hres
= pObtainUserAgentString(1, str
, &size
);
1480 ok(hres
== E_OUTOFMEMORY
, "ObtainUserAgentString failed: %08x\n", hres
);
1481 ok(size
> 0, "size=%d, expected non-zero\n", size
);
1483 str2
= HeapAlloc(GetProcessHeap(), 0, (size
+20)*sizeof(CHAR
));
1485 hres
= pObtainUserAgentString(0, str2
, &size
);
1486 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
1487 ok(size
== saved
, "size=%d, expected %d\n", size
, saved
);
1488 ok(strlen(expected
) <= strlen(str2
) &&
1489 !memcmp(expected
, str2
, strlen(expected
)*sizeof(CHAR
)),
1490 "user agent was \"%s\", expected to start with \"%s\"\n",
1494 hres
= pObtainUserAgentString(0, str2
, &size
);
1495 ok(hres
== S_OK
, "ObtainUserAgentString failed: %08x\n", hres
);
1496 ok(size
== saved
, "size=%d, expected %d\n", size
, saved
);
1499 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, NULL
, 0, &size
, 0);
1500 ok(hres
== E_OUTOFMEMORY
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1501 ok(size
, "size == 0\n");
1504 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, NULL
, 1000, &size
, 0);
1505 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1506 ok(size
, "size == 0\n");
1510 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, str2
, saved
+10, &size
, 0);
1511 ok(hres
== E_OUTOFMEMORY
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1512 ok(size
== saved
, "size = %d, expected %d\n", size
, saved
);
1513 ok(sizeof(expected
) <= strlen(str2
) && !memcmp(expected
, str2
, sizeof(expected
)-1),
1514 "user agent was \"%s\", expected to start with \"%s\"\n",
1519 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, str2
, saved
, &size
, 0);
1520 ok(hres
== E_OUTOFMEMORY
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1521 ok(size
== saved
, "size = %d, expected %d\n", size
, saved
);
1522 ok(sizeof(expected
) <= strlen(str2
) && !memcmp(expected
, str2
, sizeof(expected
)-1),
1523 "user agent was \"%s\", expected to start with \"%s\"\n",
1528 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, str2
, saved
-1, &size
, 0);
1529 ok(hres
== E_OUTOFMEMORY
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1530 ok(size
== saved
, "size = %d, expected %d\n", size
, saved
);
1531 ok(!str2
[0], "buf changed\n");
1535 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, str2
, saved
, NULL
, 0);
1536 ok(hres
== E_INVALIDARG
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1537 ok(!str2
[0], "buf changed\n");
1539 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, test_str
, sizeof(test_str
), 0);
1540 ok(hres
== S_OK
, "UrlMkSetSessionOption failed: %08x\n", hres
);
1544 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, str2
, saved
, &size
, 0);
1545 ok(hres
== E_OUTOFMEMORY
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1546 ok(size
== sizeof(test_str
) && !memcmp(str2
, test_str
, sizeof(test_str
)), "wrong user agent\n");
1548 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, test2_str
, sizeof(test2_str
), 0);
1549 ok(hres
== S_OK
, "UrlMkSetSessionOption failed: %08x\n", hres
);
1553 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, str2
, saved
, &size
, 0);
1554 ok(hres
== E_OUTOFMEMORY
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1555 ok(size
== sizeof(test_str
) && !memcmp(str2
, test_str
, sizeof(test_str
)), "wrong user agent\n");
1557 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, test_str
, 2, 0);
1558 ok(hres
== S_OK
, "UrlMkSetSessionOption failed: %08x\n", hres
);
1562 hres
= pUrlMkGetSessionOption(URLMON_OPTION_USERAGENT
, str2
, saved
, &size
, 0);
1563 ok(hres
== E_OUTOFMEMORY
, "UrlMkGetSessionOption failed: %08x\n", hres
);
1564 ok(size
== 3 && !strcmp(str2
, "te"), "wrong user agent\n");
1566 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, test_str
, 0, 0);
1567 ok(hres
== E_INVALIDARG
, "UrlMkSetSessionOption failed: %08x\n", hres
);
1569 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, NULL
, sizeof(test_str
), 0);
1570 ok(hres
== E_INVALIDARG
, "UrlMkSetSessionOption failed: %08x\n", hres
);
1572 hres
= UrlMkSetSessionOption(URLMON_OPTION_USERAGENT
, NULL
, 0, 0);
1573 ok(hres
== E_INVALIDARG
, "UrlMkSetSessionOption failed: %08x\n", hres
);
1575 HeapFree(GetProcessHeap(), 0, str2
);
1578 static void test_MkParseDisplayNameEx(void)
1580 IMoniker
*mon
= NULL
;
1587 static const WCHAR clsid_nameW
[] = {'c','l','s','i','d',':',
1588 '2','0','D','0','4','F','E','0','-','3','A','E','A','-','1','0','6','9','-','A','2','D','8',
1589 '-','0','8','0','0','2','B','3','0','3','0','9','D',':',0};
1594 LPCWSTR szDisplayName
;
1597 } invalid_parameters
[] =
1599 {NULL
, NULL
, NULL
, NULL
},
1600 {NULL
, NULL
, NULL
, &mon
},
1601 {NULL
, NULL
, &eaten
, NULL
},
1602 {NULL
, NULL
, &eaten
, &mon
},
1603 {NULL
, wszEmpty
, NULL
, NULL
},
1604 {NULL
, wszEmpty
, NULL
, &mon
},
1605 {NULL
, wszEmpty
, &eaten
, NULL
},
1606 {NULL
, wszEmpty
, &eaten
, &mon
},
1607 {&bctx
, NULL
, NULL
, NULL
},
1608 {&bctx
, NULL
, NULL
, &mon
},
1609 {&bctx
, NULL
, &eaten
, NULL
},
1610 {&bctx
, NULL
, &eaten
, &mon
},
1611 {&bctx
, wszEmpty
, NULL
, NULL
},
1612 {&bctx
, wszEmpty
, NULL
, &mon
},
1613 {&bctx
, wszEmpty
, &eaten
, NULL
},
1614 {&bctx
, wszEmpty
, &eaten
, &mon
},
1619 CreateBindCtx(0, &bctx
);
1621 for (i
= 0; i
< sizeof(invalid_parameters
)/sizeof(invalid_parameters
[0]); i
++)
1624 mon
= (IMoniker
*)0xdeadbeef;
1625 hres
= MkParseDisplayNameEx(invalid_parameters
[i
].ppbc
? *invalid_parameters
[i
].ppbc
: NULL
,
1626 invalid_parameters
[i
].szDisplayName
,
1627 invalid_parameters
[i
].pchEaten
,
1628 invalid_parameters
[i
].ppmk
);
1629 ok(hres
== E_INVALIDARG
,
1630 "[%d] Expected MkParseDisplayNameEx to return E_INVALIDARG, got %08x\n", i
, hres
);
1631 ok(eaten
== 0xdeadbeef, "[%d] Expected eaten to be 0xdeadbeef, got %u\n", i
, eaten
);
1632 ok(mon
== (IMoniker
*)0xdeadbeef, "[%d] Expected mon to be 0xdeadbeef, got %p\n", i
, mon
);
1635 hres
= MkParseDisplayNameEx(bctx
, url9
, &eaten
, &mon
);
1636 ok(hres
== S_OK
, "MkParseDisplayNameEx failed: %08x\n", hres
);
1637 ok(eaten
== sizeof(url9
)/sizeof(WCHAR
)-1, "eaten=%d\n", eaten
);
1638 ok(mon
!= NULL
, "mon == NULL\n");
1640 hres
= IMoniker_GetDisplayName(mon
, NULL
, 0, &name
);
1641 ok(hres
== S_OK
, "GetDiasplayName failed: %08x\n", hres
);
1642 ok(!lstrcmpW(name
, url9
), "wrong display name %s\n", wine_dbgstr_w(name
));
1643 CoTaskMemFree(name
);
1645 hres
= IMoniker_IsSystemMoniker(mon
, &issys
);
1646 ok(hres
== S_OK
, "IsSystemMoniker failed: %08x\n", hres
);
1647 ok(issys
== MKSYS_URLMONIKER
, "issys=%x\n", issys
);
1649 IMoniker_Release(mon
);
1651 hres
= MkParseDisplayNameEx(bctx
, clsid_nameW
, &eaten
, &mon
);
1652 ok(hres
== S_OK
, "MkParseDisplayNameEx failed: %08x\n", hres
);
1653 ok(eaten
== sizeof(clsid_nameW
)/sizeof(WCHAR
)-1, "eaten=%d\n", eaten
);
1654 ok(mon
!= NULL
, "mon == NULL\n");
1656 hres
= IMoniker_IsSystemMoniker(mon
, &issys
);
1657 ok(hres
== S_OK
, "IsSystemMoniker failed: %08x\n", hres
);
1658 ok(issys
== MKSYS_CLASSMONIKER
, "issys=%x\n", issys
);
1660 IMoniker_Release(mon
);
1662 hres
= MkParseDisplayNameEx(bctx
, url8
, &eaten
, &mon
);
1663 ok(FAILED(hres
), "MkParseDisplayNameEx succeeded: %08x\n", hres
);
1665 IBindCtx_Release(bctx
);
1668 static void test_IsValidURL(void)
1671 IBindCtx
*bctx
= NULL
;
1673 hr
= IsValidURL(NULL
, 0, 0);
1674 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %08x\n", hr
);
1676 hr
= IsValidURL(NULL
, wszHttpWineHQ
, 0);
1677 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1679 CreateBindCtx(0, &bctx
);
1681 hr
= IsValidURL(bctx
, wszHttpWineHQ
, 0);
1682 ok(hr
== S_OK
, "Expected S_OK, got %08x\n", hr
);
1684 IBindCtx_Release(bctx
);
1687 static const struct {
1688 INTERNETFEATURELIST feature
;
1692 } default_feature_tests
[] = {
1693 {FEATURE_OBJECT_CACHING
,GET_FEATURE_FROM_PROCESS
,S_OK
},
1694 {FEATURE_ZONE_ELEVATION
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1695 {FEATURE_MIME_HANDLING
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1696 {FEATURE_MIME_SNIFFING
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1697 {FEATURE_WINDOW_RESTRICTIONS
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1698 {FEATURE_WEBOC_POPUPMANAGEMENT
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1699 {FEATURE_BEHAVIORS
,GET_FEATURE_FROM_PROCESS
,S_OK
},
1700 {FEATURE_DISABLE_MK_PROTOCOL
,GET_FEATURE_FROM_PROCESS
,S_OK
},
1701 {FEATURE_LOCALMACHINE_LOCKDOWN
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1702 {FEATURE_SECURITYBAND
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1703 {FEATURE_RESTRICT_ACTIVEXINSTALL
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1704 {FEATURE_VALIDATE_NAVIGATE_URL
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1705 {FEATURE_RESTRICT_FILEDOWNLOAD
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1706 {FEATURE_ADDON_MANAGEMENT
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1707 {FEATURE_PROTOCOL_LOCKDOWN
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1708 {FEATURE_HTTP_USERNAME_PASSWORD_DISABLE
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1709 {FEATURE_SAFE_BINDTOOBJECT
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1710 {FEATURE_UNC_SAVEDFILECHECK
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1711 {FEATURE_GET_URL_DOM_FILEPATH_UNENCODED
,GET_FEATURE_FROM_PROCESS
,S_OK
},
1712 {FEATURE_TABBED_BROWSING
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1713 {FEATURE_SSLUX
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1714 {FEATURE_DISABLE_NAVIGATION_SOUNDS
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1715 {FEATURE_DISABLE_LEGACY_COMPRESSION
,GET_FEATURE_FROM_PROCESS
,S_OK
},
1716 {FEATURE_FORCE_ADDR_AND_STATUS
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1717 {FEATURE_XMLHTTP
,GET_FEATURE_FROM_PROCESS
,S_OK
},
1718 {FEATURE_DISABLE_TELNET_PROTOCOL
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1719 {FEATURE_FEEDS
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1720 {FEATURE_BLOCK_INPUT_PROMPTS
,GET_FEATURE_FROM_PROCESS
,S_FALSE
}
1723 static void test_internet_feature_defaults(void) {
1727 for(i
= 0; i
< sizeof(default_feature_tests
)/sizeof(default_feature_tests
[0]); ++i
) {
1728 hres
= pCoInternetIsFeatureEnabled(default_feature_tests
[i
].feature
, default_feature_tests
[i
].get_flags
);
1729 if(default_feature_tests
[i
].todo
) {
1731 ok(hres
== default_feature_tests
[i
].expected
, "CoInternetIsFeatureEnabled returned %08x, expected %08x on test %d\n",
1732 hres
, default_feature_tests
[i
].expected
, i
);
1734 ok(hres
== default_feature_tests
[i
].expected
, "CoInternetIsFeatureEnabled returned %08x, expected %08x on test %d\n",
1735 hres
, default_feature_tests
[i
].expected
, i
);
1740 /* With older versions of IE (IE 7 and earlier), urlmon caches
1741 * the FeatureControl values from the registry when it's loaded
1742 * into memory. Newer versions of IE conditionally cache the
1743 * the FeatureControl registry values (i.e. When a call to
1744 * CoInternetIsFeatureEnabled and a corresponding CoInternetSetFeatureEnabled
1745 * call hasn't already been made for the specified Feature). Because of
1746 * this we skip these tests on IE 7 and earlier.
1748 static void test_internet_features_registry(void) {
1751 char module
[MAX_PATH
];
1753 HKEY feature_control
;
1755 DWORD value
, skip_zone
;
1756 BOOL delete_feature_key
= TRUE
;
1757 BOOL delete_feature_control_key
= FALSE
;
1759 static const char* szFeatureControlKey
= "Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl";
1760 static const char* szFeatureBehaviorsKey
= "FEATURE_BEHAVIORS";
1761 static const char* szFeatureZoneElevationKey
= "FEATURE_ZONE_ELEVATION";
1763 if(!pIEInstallScope
) {
1764 win_skip("Skipping internet feature registry tests, IE is too old...\n");
1768 res
= GetModuleFileNameA(NULL
, module
, sizeof(module
));
1769 ok(res
, "GetModuleFileName failed: %d\n", GetLastError());
1771 name
= strrchr(module
, '\\')+1;
1773 /* Some Windows machines don't have a FeatureControl key in HKCU. */
1774 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szFeatureControlKey
, &feature_control
);
1775 if(res
!= ERROR_SUCCESS
) {
1776 res
= RegCreateKeyA(HKEY_CURRENT_USER
, szFeatureControlKey
, &feature_control
);
1777 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
1778 delete_feature_control_key
= TRUE
;
1781 res
= RegOpenKeyA(feature_control
, szFeatureBehaviorsKey
, &feature
);
1782 if(res
== ERROR_SUCCESS
)
1783 /* FEATURE_BEHAVIORS already existed, so don't delete it when we're done. */
1784 delete_feature_key
= FALSE
;
1786 res
= RegCreateKeyA(feature_control
, szFeatureBehaviorsKey
, &feature
);
1787 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
1791 res
= RegSetValueExA(feature
, name
, 0, REG_DWORD
, (BYTE
*)&value
, sizeof(DWORD
));
1792 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
1794 hres
= pCoInternetIsFeatureEnabled(FEATURE_BEHAVIORS
, GET_FEATURE_FROM_PROCESS
);
1795 ok(hres
== S_FALSE
, "CoInternetIsFeatureEnabled returned %08x, expected S_FALSE\n", hres
);
1797 if(delete_feature_key
) {
1798 RegCloseKey(feature
);
1799 RegDeleteKeyA(feature_control
, szFeatureBehaviorsKey
);
1801 RegDeleteValue(feature
, name
);
1802 RegCloseKey(feature
);
1805 /* IE's feature control cached the value it got from the registry earlier. */
1806 hres
= pCoInternetIsFeatureEnabled(FEATURE_BEHAVIORS
, GET_FEATURE_FROM_PROCESS
);
1807 ok(hres
== S_FALSE
, "CoInternetIsFeatureEnabled returned %08x, expected S_FALSE\n", hres
);
1809 /* Restore this feature back to its default value. */
1810 hres
= pCoInternetSetFeatureEnabled(FEATURE_BEHAVIORS
, SET_FEATURE_ON_PROCESS
, TRUE
);
1811 ok(hres
== S_OK
, "CoInternetSetFeatureEnabled failed: %08x\n", hres
);
1813 RegCloseKey(feature_control
);
1814 if(delete_feature_control_key
)
1815 RegDeleteKeyA(HKEY_CURRENT_USER
, szFeatureControlKey
);
1817 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szFeatureControlKey
, &feature_control
);
1818 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
1820 res
= RegOpenKeyA(feature_control
, szFeatureZoneElevationKey
, &feature
);
1821 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
1824 res
= RegSetValueExA(feature
, "*", 0, REG_DWORD
, (BYTE
*)&value
, sizeof(DWORD
));
1825 if (res
== ERROR_ACCESS_DENIED
)
1827 skip("Not allowed to modify zone elevation\n");
1833 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
1835 hres
= pCoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, GET_FEATURE_FROM_PROCESS
);
1836 ok(hres
== S_OK
, "CoInternetIsFeatureEnabled returned %08x, expected S_OK\n", hres
);
1838 RegDeleteValueA(feature
, "*");
1839 RegCloseKey(feature
);
1840 RegCloseKey(feature_control
);
1842 /* Value is still cached from last time. */
1845 hres
= pCoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, GET_FEATURE_FROM_PROCESS
);
1846 ok(hres
== S_OK
, "CoInternetIsFeatureEnabled returned %08x, expected S_OK\n", hres
);
1848 hres
= pCoInternetSetFeatureEnabled(FEATURE_ZONE_ELEVATION
, SET_FEATURE_ON_PROCESS
, FALSE
);
1849 ok(hres
== S_OK
, "CoInternetSetFeatureEnabled failed: %08x\n", hres
);
1852 test_internet_feature_defaults();
1855 static void test_CoInternetIsFeatureEnabled(void) {
1858 hres
= pCoInternetIsFeatureEnabled(FEATURE_ENTRY_COUNT
, GET_FEATURE_FROM_PROCESS
);
1859 ok(hres
== E_FAIL
, "CoInternetIsFeatureEnabled returned %08x, expected E_FAIL\n", hres
);
1862 static const struct {
1863 INTERNETFEATURELIST feature
;
1866 HRESULT set_expected
;
1869 HRESULT get_expected
;
1871 } internet_feature_tests
[] = {
1872 {FEATURE_OBJECT_CACHING
,SET_FEATURE_ON_PROCESS
,FALSE
,S_OK
,FALSE
,GET_FEATURE_FROM_PROCESS
,S_FALSE
},
1873 {FEATURE_WEBOC_POPUPMANAGEMENT
,SET_FEATURE_ON_PROCESS
,TRUE
,S_OK
,FALSE
,GET_FEATURE_FROM_PROCESS
,S_OK
},
1874 {FEATURE_LOCALMACHINE_LOCKDOWN
,SET_FEATURE_ON_PROCESS
,TRUE
,S_OK
,FALSE
,GET_FEATURE_FROM_PROCESS
,S_OK
}
1877 static void test_CoInternetSetFeatureEnabled(void) {
1881 hres
= pCoInternetSetFeatureEnabled(FEATURE_ENTRY_COUNT
,SET_FEATURE_ON_PROCESS
,TRUE
);
1882 ok(hres
== E_FAIL
, "CoInternetSetFeatureEnabled returned %08x, expected E_FAIL\n", hres
);
1884 for(i
= 0; i
< sizeof(internet_feature_tests
)/sizeof(internet_feature_tests
[0]); ++i
) {
1885 hres
= pCoInternetSetFeatureEnabled(internet_feature_tests
[i
].feature
, internet_feature_tests
[i
].set_flags
,
1886 internet_feature_tests
[i
].enable
);
1887 if(internet_feature_tests
[i
].set_todo
) {
1889 ok(hres
== internet_feature_tests
[i
].set_expected
, "CoInternetSetFeatureEnabled returned %08x, expected %08x on test %d\n",
1890 hres
, internet_feature_tests
[i
].set_expected
, i
);
1892 ok(hres
== internet_feature_tests
[i
].set_expected
, "CoInternetSetFeatureEnabled returned %08x, expected %08x on test %d\n",
1893 hres
, internet_feature_tests
[i
].set_expected
, i
);
1896 hres
= pCoInternetIsFeatureEnabled(internet_feature_tests
[i
].feature
, internet_feature_tests
[i
].set_flags
);
1897 if(internet_feature_tests
[i
].get_todo
) {
1899 ok(hres
== internet_feature_tests
[i
].get_expected
, "CoInternetIsFeatureEnabled returned %08x, expected %08x on test %d\n",
1900 hres
, internet_feature_tests
[i
].get_expected
, i
);
1902 ok(hres
== internet_feature_tests
[i
].get_expected
, "CoInternetIsFeatureEnabled returned %08x, expected %08x on test %d\n",
1903 hres
, internet_feature_tests
[i
].get_expected
, i
);
1908 static void test_internet_features(void) {
1909 if(!pCoInternetIsFeatureEnabled
|| !pCoInternetSetFeatureEnabled
) {
1910 win_skip("Skipping internet feature tests, IE is too old\n");
1914 test_internet_features_registry();
1915 test_CoInternetIsFeatureEnabled();
1916 test_CoInternetSetFeatureEnabled();
1923 hurlmon
= GetModuleHandle("urlmon.dll");
1924 pCoInternetCompareUrl
= (void *) GetProcAddress(hurlmon
, "CoInternetCompareUrl");
1925 pCoInternetGetSecurityUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrl");
1926 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
1927 pCoInternetParseUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetParseUrl");
1928 pCoInternetQueryInfo
= (void*) GetProcAddress(hurlmon
, "CoInternetQueryInfo");
1929 pCopyStgMedium
= (void*) GetProcAddress(hurlmon
, "CopyStgMedium");
1930 pCopyBindInfo
= (void*) GetProcAddress(hurlmon
, "CopyBindInfo");
1931 pFindMimeFromData
= (void*) GetProcAddress(hurlmon
, "FindMimeFromData");
1932 pObtainUserAgentString
= (void*) GetProcAddress(hurlmon
, "ObtainUserAgentString");
1933 pReleaseBindInfo
= (void*) GetProcAddress(hurlmon
, "ReleaseBindInfo");
1934 pUrlMkGetSessionOption
= (void*) GetProcAddress(hurlmon
, "UrlMkGetSessionOption");
1935 pCompareSecurityIds
= (void*) GetProcAddress(hurlmon
, "CompareSecurityIds");
1936 pCoInternetIsFeatureEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabled");
1937 pCoInternetSetFeatureEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetSetFeatureEnabled");
1938 pIEInstallScope
= (void*) GetProcAddress(hurlmon
, "IEInstallScope");
1940 if (!pCoInternetCompareUrl
|| !pCoInternetGetSecurityUrl
||
1941 !pCoInternetGetSession
|| !pCoInternetParseUrl
|| !pCompareSecurityIds
) {
1942 win_skip("Various needed functions not present, too old IE\n");
1946 OleInitialize(NULL
);
1948 register_protocols();
1950 test_CreateFormatEnum();
1951 test_RegisterFormatEnumerator();
1952 test_CoInternetParseUrl();
1953 test_CoInternetCompareUrl();
1954 test_CoInternetQueryInfo();
1955 test_FindMimeFromData();
1958 test_ReleaseBindInfo();
1959 test_CopyStgMedium();
1960 test_CopyBindInfo();
1961 test_UrlMkGetSessionOption();
1963 test_MkParseDisplayNameEx();
1965 test_internet_features();