4 * Copyright 2004 Kevin Koltzau
5 * Copyright 2004-2007 Jacek Caban for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define NONAMELESSUNION
36 #include "wine/test.h"
38 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
39 DEFINE_GUID(CLSID_IdentityUnmarshal
,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
40 DEFINE_GUID(IID_IBindStatusCallbackHolder
,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
42 #define DEFINE_EXPECT(func) \
43 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
45 #define SET_EXPECT(func) \
46 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
48 #define CHECK_EXPECT2(func) \
50 ok(expect_ ##func, "unexpected call " #func "\n"); \
51 called_ ## func = TRUE; \
54 #define CHECK_EXPECT(func) \
56 CHECK_EXPECT2(func); \
57 expect_ ## func = FALSE; \
60 #define CHECK_CALLED(func) \
62 ok(called_ ## func, "expected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
66 #define CHECK_NOT_CALLED(func) \
68 ok(!called_ ## func, "unexpected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
72 #define CHECK_CALLED_BROKEN(func) \
74 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
75 expect_ ## func = called_ ## func = FALSE; \
78 #define CLEAR_CALLED(func) \
79 expect_ ## func = called_ ## func = FALSE
81 DEFINE_EXPECT(QueryInterface_IServiceProvider
);
82 DEFINE_EXPECT(QueryInterface_IHttpNegotiate
);
83 DEFINE_EXPECT(QueryInterface_IBindStatusCallback
);
84 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder
);
85 DEFINE_EXPECT(QueryInterface_IInternetBindInfo
);
86 DEFINE_EXPECT(QueryInterface_IAuthenticate
);
87 DEFINE_EXPECT(QueryInterface_IInternetProtocol
);
88 DEFINE_EXPECT(QueryService_IAuthenticate
);
89 DEFINE_EXPECT(QueryService_IInternetProtocol
);
90 DEFINE_EXPECT(QueryService_IInternetBindInfo
);
91 DEFINE_EXPECT(BeginningTransaction
);
92 DEFINE_EXPECT(OnResponse
);
93 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2
);
94 DEFINE_EXPECT(GetRootSecurityId
);
95 DEFINE_EXPECT(GetBindInfo
);
96 DEFINE_EXPECT(OnStartBinding
);
97 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE
);
98 DEFINE_EXPECT(OnProgress_CONNECTING
);
99 DEFINE_EXPECT(OnProgress_SENDINGREQUEST
);
100 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
101 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
102 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA
);
103 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA
);
104 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
105 DEFINE_EXPECT(OnStopBinding
);
106 DEFINE_EXPECT(OnDataAvailable
);
107 DEFINE_EXPECT(OnObjectAvailable
);
108 DEFINE_EXPECT(Obj_OnStartBinding
);
109 DEFINE_EXPECT(Obj_OnStopBinding
);
110 DEFINE_EXPECT(Obj_GetBindInfo
);
111 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
112 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
113 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
114 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
115 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
116 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
117 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
118 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
119 DEFINE_EXPECT(Obj_OnProgress_CONNECTING
);
120 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
121 DEFINE_EXPECT(Start
);
123 DEFINE_EXPECT(LockRequest
);
124 DEFINE_EXPECT(Terminate
);
125 DEFINE_EXPECT(UnlockRequest
);
126 DEFINE_EXPECT(Continue
);
127 DEFINE_EXPECT(CreateInstance
);
129 DEFINE_EXPECT(PutProperty_MIMETYPEPROP
);
130 DEFINE_EXPECT(PutProperty_CLASSIDPROP
);
131 DEFINE_EXPECT(SetPriority
);
133 static const WCHAR TEST_URL_1
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
134 static const WCHAR TEST_PART_URL_1
[] = {'/','t','e','s','t','/','\0'};
136 static const WCHAR WINE_ABOUT_URL
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
137 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
138 static const WCHAR SHORT_RESPONSE_URL
[] =
139 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
140 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
141 'p','o','s','t','t','e','s','t','.','p','h','p',0};
142 static const WCHAR ABOUT_BLANK
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
143 static WCHAR INDEX_HTML
[MAX_PATH
];
144 static const WCHAR ITS_URL
[] =
145 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
146 static const WCHAR MK_URL
[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
147 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
148 static const WCHAR https_urlW
[] =
149 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',
150 '/','t','e','s','t','.','h','t','m','l',0};
151 static const WCHAR ftp_urlW
[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
152 '/','p','u','b','/','o','t','h','e','r','/',
153 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
156 static const WCHAR wszTextHtml
[] = {'t','e','x','t','/','h','t','m','l',0};
158 static WCHAR BSCBHolder
[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
160 static const WCHAR wszWineHQSite
[] =
161 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
162 static const WCHAR wszWineHQIP
[] =
163 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
164 static const CHAR wszIndexHtmlA
[] = "index.html";
165 static const WCHAR wszIndexHtml
[] = {'i','n','d','e','x','.','h','t','m','l',0};
166 static const WCHAR cache_fileW
[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
167 static const CHAR dwl_htmlA
[] = "dwl.html";
168 static const WCHAR dwl_htmlW
[] = {'d','w','l','.','h','t','m','l',0};
169 static const WCHAR emptyW
[] = {0};
171 static BOOL stopped_binding
= FALSE
, stopped_obj_binding
= FALSE
, emulate_protocol
= FALSE
,
172 data_available
= FALSE
, http_is_first
= TRUE
, bind_to_object
= FALSE
, filedwl_api
;
173 static DWORD read
= 0, bindf
= 0, prot_state
= 0, thread_id
, tymed
;
174 static CHAR mime_type
[512];
175 static IInternetProtocolSink
*protocol_sink
= NULL
;
176 static IBinding
*current_binding
;
177 static HANDLE complete_event
, complete_event2
;
178 static HRESULT binding_hres
;
179 static BOOL have_IHttpNegotiate2
;
181 static LPCWSTR urls
[] = {
191 static WCHAR file_url
[INTERNET_MAX_URL_LENGTH
];
209 static const char *debugstr_w(LPCWSTR str
)
211 static char buf
[1024];
212 WideCharToMultiByte(CP_ACP
, 0, str
, -1, buf
, sizeof(buf
), NULL
, NULL
);
216 static const char *debugstr_guid(REFIID riid
)
220 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
221 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
222 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
223 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
228 static BOOL
is_urlmon_protocol(int prot
)
230 return prot
== FILE_TEST
|| prot
== HTTP_TEST
|| prot
== HTTPS_TEST
|| prot
== FTP_TEST
|| prot
== MK_TEST
;
233 static void test_CreateURLMoniker(LPCWSTR url1
, LPCWSTR url2
)
236 IMoniker
*mon1
= NULL
;
237 IMoniker
*mon2
= NULL
;
239 hr
= CreateURLMoniker(NULL
, url1
, &mon1
);
240 ok(SUCCEEDED(hr
), "failed to create moniker: 0x%08x\n", hr
);
242 hr
= CreateURLMoniker(mon1
, url2
, &mon2
);
243 ok(SUCCEEDED(hr
), "failed to create moniker: 0x%08x\n", hr
);
245 if(mon1
) IMoniker_Release(mon1
);
246 if(mon2
) IMoniker_Release(mon2
);
249 static void test_create(void)
251 test_CreateURLMoniker(TEST_URL_1
, TEST_PART_URL_1
);
254 static HRESULT WINAPI
Priority_QueryInterface(IInternetPriority
*iface
, REFIID riid
, void **ppv
)
256 ok(0, "unexpected call\n");
257 return E_NOINTERFACE
;
260 static ULONG WINAPI
Priority_AddRef(IInternetPriority
*iface
)
265 static ULONG WINAPI
Priority_Release(IInternetPriority
*iface
)
270 static HRESULT WINAPI
Priority_SetPriority(IInternetPriority
*iface
, LONG nPriority
)
272 CHECK_EXPECT(SetPriority
);
273 ok(!nPriority
, "nPriority = %d\n", nPriority
);
277 static HRESULT WINAPI
Priority_GetPriority(IInternetPriority
*iface
, LONG
*pnPriority
)
279 ok(0, "unexpected call\n");
283 static const IInternetPriorityVtbl InternetPriorityVtbl
= {
284 Priority_QueryInterface
,
287 Priority_SetPriority
,
291 static IInternetPriority InternetPriority
= { &InternetPriorityVtbl
};
293 static HRESULT WINAPI
Protocol_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
297 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
302 if(IsEqualGUID(&IID_IInternetPriority
, riid
)) {
303 if(!is_urlmon_protocol(test_protocol
))
304 return E_NOINTERFACE
;
306 *ppv
= &InternetPriority
;
310 if(IsEqualGUID(&IID_IInternetProtocolEx
, riid
))
311 return E_NOINTERFACE
; /* TODO */
313 ok(0, "unexpected call %s\n", debugstr_guid(riid
));
314 return E_NOINTERFACE
;
317 static ULONG WINAPI
Protocol_AddRef(IInternetProtocol
*iface
)
322 static ULONG WINAPI
Protocol_Release(IInternetProtocol
*iface
)
327 static void test_switch_fail(void)
329 IInternetProtocolSink
*binding_sink
;
330 PROTOCOLDATA protocoldata
;
333 static BOOL tested_switch_fail
;
335 if(tested_switch_fail
)
338 tested_switch_fail
= TRUE
;
340 hres
= IBinding_QueryInterface(current_binding
, &IID_IInternetProtocolSink
, (void**)&binding_sink
);
341 ok(hres
== S_OK
, "Could not get IInternetProtocolSink iface: %08x\n", hres
);
342 if(SUCCEEDED(hres
)) {
343 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
344 ok(hres
== E_FAIL
, "Switch failed: %08x, expected E_FAIL\n", hres
);
345 IInternetProtocolSink_Release(binding_sink
);
349 static DWORD WINAPI
thread_proc(PVOID arg
)
351 PROTOCOLDATA protocoldata
;
355 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
357 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
358 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
359 BINDSTATUS_FINDINGRESOURCE
, wszWineHQSite
);
360 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
361 WaitForSingleObject(complete_event
, INFINITE
);
363 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
365 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
368 SET_EXPECT(Obj_OnProgress_CONNECTING
);
370 SET_EXPECT(OnProgress_CONNECTING
);
371 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
372 BINDSTATUS_CONNECTING
, wszWineHQIP
);
373 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
374 WaitForSingleObject(complete_event
, INFINITE
);
376 CHECK_CALLED(Obj_OnProgress_CONNECTING
);
378 CHECK_CALLED(OnProgress_CONNECTING
);
381 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
383 SET_EXPECT(OnProgress_SENDINGREQUEST
);
384 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
385 BINDSTATUS_SENDINGREQUEST
, NULL
);
386 ok(hres
== S_OK
, "ReportProxgress failed: %08x\n", hres
);
387 WaitForSingleObject(complete_event
, INFINITE
);
389 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
391 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
395 SET_EXPECT(Continue
);
397 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
398 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
399 WaitForSingleObject(complete_event
, INFINITE
);
401 CHECK_CALLED(Continue
);
404 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
405 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
406 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
407 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
408 CHECK_CALLED(CreateInstance
);
409 CHECK_CALLED(PutProperty_MIMETYPEPROP
);
410 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP
);
412 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
413 CHECK_CALLED(OnObjectAvailable
);
414 CHECK_CALLED(Obj_OnStopBinding
);
416 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
417 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
418 CHECK_CALLED(LockRequest
);
419 CHECK_CALLED(OnDataAvailable
);
422 SET_EXPECT(Continue
);
424 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
425 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
426 WaitForSingleObject(complete_event
, INFINITE
);
427 CHECK_CALLED(Continue
);
429 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
430 CHECK_CALLED(OnDataAvailable
);
432 SET_EXPECT(Continue
);
434 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
435 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
436 WaitForSingleObject(complete_event
, INFINITE
);
437 CHECK_CALLED(Continue
);
439 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
440 CHECK_CALLED(OnDataAvailable
);
442 SET_EXPECT(Continue
);
444 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
445 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
446 WaitForSingleObject(complete_event
, INFINITE
);
447 CHECK_CALLED(Continue
);
449 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
450 CHECK_CALLED(OnDataAvailable
);
451 CHECK_CALLED(OnStopBinding
);
455 SetEvent(complete_event2
);
459 static HRESULT WINAPI
Protocol_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
460 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
461 DWORD grfPI
, HANDLE_PTR dwReserved
)
464 DWORD bindf
, bscf
= BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
;
467 static const STGMEDIUM stgmed_zero
= {0};
468 static const SECURITY_ATTRIBUTES sa_zero
= {0};
474 if(!filedwl_api
) /* FIXME */
475 ok(szUrl
&& !lstrcmpW(szUrl
, urls
[test_protocol
]), "wrong url %s\n", debugstr_w(szUrl
));
476 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
477 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
478 ok(grfPI
== 0, "grfPI=%d, expected 0\n", grfPI
);
479 ok(dwReserved
== 0, "dwReserved=%lx, expected 0\n", dwReserved
);
481 if(!filedwl_api
&& binding_hres
!= S_OK
) {
482 SET_EXPECT(OnStopBinding
);
483 SET_EXPECT(Terminate
);
484 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, binding_hres
, 0, NULL
);
485 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
486 CHECK_CALLED(OnStopBinding
);
487 CHECK_CALLED(Terminate
);
492 memset(&bindinfo
, 0, sizeof(bindinfo
));
493 bindinfo
.cbSize
= sizeof(bindinfo
);
494 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &bindf
, &bindinfo
);
495 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
498 ok(bindf
== (BINDF_PULLDATA
|BINDF_FROMURLMON
|BINDF_NEEDFILE
), "bindf=%08x\n", bindf
);
499 }else if(tymed
== TYMED_ISTREAM
&& is_urlmon_protocol(test_protocol
)) {
500 ok(bindf
== (BINDF_ASYNCHRONOUS
|BINDF_ASYNCSTORAGE
|BINDF_PULLDATA
502 "bindf=%08x\n", bindf
);
504 ok(bindf
== (BINDF_ASYNCHRONOUS
|BINDF_ASYNCSTORAGE
|BINDF_PULLDATA
505 |BINDF_FROMURLMON
|BINDF_NEEDFILE
),
506 "bindf=%08x\n", bindf
);
509 ok(bindinfo
.cbSize
== sizeof(bindinfo
), "bindinfo.cbSize = %d\n", bindinfo
.cbSize
);
510 ok(!bindinfo
.szExtraInfo
, "bindinfo.szExtraInfo = %p\n", bindinfo
.szExtraInfo
);
511 ok(!memcmp(&bindinfo
.stgmedData
, &stgmed_zero
, sizeof(STGMEDIUM
)), "wrong stgmedData\n");
512 ok(!bindinfo
.grfBindInfoF
, "bindinfo.grfBindInfoF = %d\n", bindinfo
.grfBindInfoF
);
513 ok(!bindinfo
.dwBindVerb
, "bindinfo.dwBindVerb = %d\n", bindinfo
.dwBindVerb
);
514 ok(!bindinfo
.szCustomVerb
, "bindinfo.szCustomVerb = %p\n", bindinfo
.szCustomVerb
);
515 ok(!bindinfo
.cbstgmedData
, "bindinfo.cbstgmedData = %d\n", bindinfo
.cbstgmedData
);
516 ok(bindinfo
.dwOptions
== (bind_to_object
? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo
.dwOptions
);
517 ok(!bindinfo
.dwOptionsFlags
, "bindinfo.dwOptionsFlags = %d\n", bindinfo
.dwOptionsFlags
);
518 ok(!bindinfo
.dwCodePage
, "bindinfo.dwCodePage = %d\n", bindinfo
.dwCodePage
);
519 ok(!memcmp(&bindinfo
.securityAttributes
, &sa_zero
, sizeof(sa_zero
)), "wrong bindinfo.securityAttributes\n");
520 ok(IsEqualGUID(&bindinfo
.iid
, &IID_NULL
), "wrong bindinfo.iid\n");
521 ok(!bindinfo
.pUnk
, "bindinfo.pUnk = %p\n", bindinfo
.pUnk
);
522 ok(!bindinfo
.dwReserved
, "bindinfo.dwReserved = %d\n", bindinfo
.dwReserved
);
524 switch(test_protocol
) {
526 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
527 BINDSTATUS_DIRECTBIND
, NULL
);
529 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
534 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
536 SET_EXPECT(OnProgress_SENDINGREQUEST
);
537 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
538 BINDSTATUS_SENDINGREQUEST
, emptyW
);
540 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
542 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
544 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
549 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
550 IServiceProvider
*service_provider
;
551 IHttpNegotiate
*http_negotiate
;
552 IHttpNegotiate2
*http_negotiate2
;
553 LPWSTR ua
= (LPWSTR
)0xdeadbeef, accept_mimes
[256];
554 LPWSTR additional_headers
= (LPWSTR
)0xdeadbeef;
556 DWORD fetched
= 256, size
= 100;
559 static const WCHAR wszMimes
[] = {'*','/','*',0};
561 SET_EXPECT(QueryInterface_IInternetBindInfo
);
562 SET_EXPECT(QueryService_IInternetBindInfo
);
563 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_USER_AGENT
,
566 CHECK_CALLED(QueryInterface_IInternetBindInfo
);
567 CHECK_CALLED(QueryService_IInternetBindInfo
);
569 ok(hres
== E_NOINTERFACE
,
570 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres
);
571 ok(fetched
== 256, "fetched = %d, expected 254\n", fetched
);
572 ok(ua
== (LPWSTR
)0xdeadbeef, "ua = %p\n", ua
);
574 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
575 accept_mimes
, 256, &fetched
);
577 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
578 ok(fetched
== 1, "fetched = %d, expected 1\n", fetched
);
579 ok(!lstrcmpW(wszMimes
, accept_mimes
[0]), "unexpected mimes\n");
581 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
582 NULL
, 256, &fetched
);
583 ok(hres
== E_INVALIDARG
,
584 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
586 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
587 accept_mimes
, 256, NULL
);
588 ok(hres
== E_INVALIDARG
,
589 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
591 hres
= IInternetBindInfo_QueryInterface(pOIBindInfo
, &IID_IServiceProvider
,
592 (void**)&service_provider
);
593 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
595 SET_EXPECT(QueryInterface_IHttpNegotiate
);
596 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
597 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
598 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
599 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
601 SET_EXPECT(BeginningTransaction
);
602 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, urls
[test_protocol
],
603 NULL
, 0, &additional_headers
);
604 CHECK_CALLED(BeginningTransaction
);
605 IHttpNegotiate_Release(http_negotiate
);
606 ok(hres
== S_OK
, "BeginningTransction failed: %08x\n", hres
);
607 ok(additional_headers
== NULL
, "additional_headers=%p\n", additional_headers
);
609 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
610 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate2
,
611 &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
612 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
613 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
616 SET_EXPECT(GetRootSecurityId
);
617 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, sec_id
, &size
, 0);
618 CHECK_CALLED(GetRootSecurityId
);
619 IHttpNegotiate2_Release(http_negotiate2
);
620 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres
);
621 ok(size
== 13, "size=%d\n", size
);
623 IServiceProvider_Release(service_provider
);
625 IInternetProtocolSink_AddRef(pOIProtSink
);
626 protocol_sink
= pOIProtSink
;
627 CreateThread(NULL
, 0, thread_proc
, NULL
, 0, &tid
);
632 if(test_protocol
== FILE_TEST
) {
633 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
634 BINDSTATUS_CACHEFILENAMEAVAILABLE
, file_url
+8);
636 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
639 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
641 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
642 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
643 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
, wszTextHtml
);
645 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres
);
647 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
649 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
651 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
652 BINDSTATUS_MIMETYPEAVAILABLE
, wszTextHtml
);
654 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
657 if(test_protocol
== ABOUT_TEST
)
658 bscf
|= BSCF_DATAFULLYAVAILABLE
;
659 if(test_protocol
== ITS_TEST
)
660 bscf
= BSCF_FIRSTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
;
664 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
665 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
666 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
667 if(test_protocol
== FILE_TEST
)
668 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
669 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
670 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
671 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
672 SET_EXPECT(CreateInstance
);
673 SET_EXPECT(PutProperty_MIMETYPEPROP
);
674 SET_EXPECT(PutProperty_CLASSIDPROP
);
676 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
677 SET_EXPECT(OnObjectAvailable
);
678 SET_EXPECT(Obj_OnStopBinding
);
680 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
681 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
682 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
683 if(test_protocol
== FILE_TEST
)
684 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
685 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
686 SET_EXPECT(LockRequest
);
688 SET_EXPECT(OnDataAvailable
);
689 SET_EXPECT(OnStopBinding
);
692 hres
= IInternetProtocolSink_ReportData(pOIProtSink
, bscf
, 13, 13);
693 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
697 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
698 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
699 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
700 if(test_protocol
== FILE_TEST
)
701 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
702 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA
);
703 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
704 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
705 CHECK_CALLED(CreateInstance
);
706 CHECK_CALLED(PutProperty_MIMETYPEPROP
);
707 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP
);
709 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
710 CHECK_CALLED(OnObjectAvailable
);
711 CHECK_CALLED(Obj_OnStopBinding
);
713 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
714 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
715 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
716 if(test_protocol
== FILE_TEST
)
717 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
718 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
719 CHECK_CALLED(LockRequest
);
721 CHECK_CALLED(OnDataAvailable
);
722 CHECK_CALLED(OnStopBinding
);
725 if(test_protocol
== ITS_TEST
) {
727 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_BEGINDOWNLOADDATA
, NULL
);
728 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres
);
732 SET_EXPECT(Terminate
);
733 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, S_OK
, 0, NULL
);
734 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
735 CHECK_CALLED(Terminate
);
740 static HRESULT WINAPI
Protocol_Continue(IInternetProtocol
*iface
,
741 PROTOCOLDATA
*pProtocolData
)
746 CHECK_EXPECT(Continue
);
748 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
750 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
756 IServiceProvider
*service_provider
;
757 IHttpNegotiate
*http_negotiate
;
758 static WCHAR header
[] = {'?',0};
760 hres
= IInternetProtocolSink_QueryInterface(protocol_sink
, &IID_IServiceProvider
,
761 (void**)&service_provider
);
762 ok(hres
== S_OK
, "Could not get IServiceProvicder\n");
764 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
765 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
766 ok(hres
== S_OK
, "Could not get IHttpNegotiate\n");
768 SET_EXPECT(OnResponse
);
769 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, header
, NULL
, NULL
);
770 CHECK_CALLED(OnResponse
);
771 IHttpNegotiate_Release(http_negotiate
);
772 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
774 if(test_protocol
== HTTPS_TEST
) {
775 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
, BINDSTATUS_ACCEPTRANGES
, NULL
);
776 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres
);
779 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
780 BINDSTATUS_MIMETYPEAVAILABLE
, wszTextHtml
);
782 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
784 if(tymed
== TYMED_FILE
) {
785 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
786 BINDSTATUS_CACHEFILENAMEAVAILABLE
, cache_fileW
);
788 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
791 bscf
|= BSCF_FIRSTDATANOTIFICATION
;
796 bscf
= BSCF_INTERMEDIATEDATANOTIFICATION
;
800 hres
= IInternetProtocolSink_ReportData(protocol_sink
, bscf
, 100, 400);
801 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
807 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
808 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
809 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
810 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
811 SET_EXPECT(CreateInstance
);
812 SET_EXPECT(PutProperty_MIMETYPEPROP
);
813 SET_EXPECT(PutProperty_CLASSIDPROP
);
815 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
816 SET_EXPECT(OnObjectAvailable
);
817 SET_EXPECT(Obj_OnStopBinding
);
819 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
820 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
821 SET_EXPECT(LockRequest
);
825 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
828 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
829 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
831 if(!bind_to_object
|| prot_state
>= 2)
832 SET_EXPECT(OnDataAvailable
);
834 SET_EXPECT(OnStopBinding
);
839 static HRESULT WINAPI
Protocol_Abort(IInternetProtocol
*iface
, HRESULT hrReason
,
842 ok(0, "unexpected call\n");
846 static HRESULT WINAPI
Protocol_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
848 CHECK_EXPECT(Terminate
);
850 ok(dwOptions
== 0, "dwOptions=%d, expected 0\n", dwOptions
);
853 IInternetProtocolSink_Release(protocol_sink
);
854 protocol_sink
= NULL
;
860 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocol
*iface
)
862 ok(0, "unexpected call\n");
866 static HRESULT WINAPI
Protocol_Resume(IInternetProtocol
*iface
)
868 ok(0, "unexpected call\n");
872 static HRESULT WINAPI
Protocol_Read(IInternetProtocol
*iface
, void *pv
,
873 ULONG cb
, ULONG
*pcbRead
)
875 static const char data
[] = "<HTML></HTML>";
879 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
882 static BOOL pending
= TRUE
;
904 hres
= IInternetProtocolSink_ReportData(protocol_sink
,
905 BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
, 2000, 2000);
906 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
908 hres
= IInternetProtocolSink_ReportResult(protocol_sink
, S_OK
, 0, NULL
);
909 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
923 ok(pv
!= NULL
, "pv == NULL\n");
924 ok(cb
!= 0, "cb == 0\n");
925 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
927 ok(*pcbRead
== 0, "*pcbRead=%d, expected 0\n", *pcbRead
);
928 read
+= *pcbRead
= sizeof(data
)-1;
931 memcpy(pv
, data
, sizeof(data
));
936 static HRESULT WINAPI
Protocol_Seek(IInternetProtocol
*iface
,
937 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
939 ok(0, "unexpected call\n");
943 static HRESULT WINAPI
Protocol_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
945 CHECK_EXPECT(LockRequest
);
949 static HRESULT WINAPI
Protocol_UnlockRequest(IInternetProtocol
*iface
)
951 CHECK_EXPECT(UnlockRequest
);
955 static const IInternetProtocolVtbl ProtocolVtbl
= {
956 Protocol_QueryInterface
,
967 Protocol_LockRequest
,
968 Protocol_UnlockRequest
971 static IInternetProtocol Protocol
= { &ProtocolVtbl
};
973 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
, REFIID riid
, void **ppv
)
975 if(IsEqualGUID(&IID_IUnknown
, riid
)
976 || IsEqualGUID(&IID_IHttpNegotiate
, riid
)
977 || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
982 ok(0, "unexpected call\n");
983 return E_NOINTERFACE
;
986 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
991 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
996 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
, LPCWSTR szURL
,
997 LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
999 CHECK_EXPECT(BeginningTransaction
);
1001 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1003 ok(!lstrcmpW(szURL
, urls
[test_protocol
]), "szURL != urls[test_protocol]\n");
1004 ok(!dwReserved
, "dwReserved=%d, expected 0\n", dwReserved
);
1005 ok(pszAdditionalHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
1006 if(pszAdditionalHeaders
)
1007 ok(*pszAdditionalHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
1012 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
1013 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
1015 CHECK_EXPECT(OnResponse
);
1017 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1019 ok(dwResponseCode
== 200, "dwResponseCode=%d, expected 200\n", dwResponseCode
);
1020 ok(szResponseHeaders
!= NULL
, "szResponseHeaders == NULL\n");
1021 ok(szRequestHeaders
== NULL
, "szRequestHeaders != NULL\n");
1022 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1023 ok(pszAdditionalRequestHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
1024 if(pszAdditionalRequestHeaders
)
1025 ok(*pszAdditionalRequestHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
1030 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
1031 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
1033 static const BYTE sec_id
[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1035 CHECK_EXPECT(GetRootSecurityId
);
1037 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1039 ok(!dwReserved
, "dwReserved=%ld, expected 0\n", dwReserved
);
1040 ok(pbSecurityId
!= NULL
, "pbSecurityId == NULL\n");
1041 ok(pcbSecurityId
!= NULL
, "pcbSecurityId == NULL\n");
1043 if(pbSecurityId
== (void*)0xdeadbeef)
1047 ok(*pcbSecurityId
== 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId
);
1048 *pcbSecurityId
= sizeof(sec_id
);
1052 memcpy(pbSecurityId
, sec_id
, sizeof(sec_id
));
1057 static IHttpNegotiate2Vtbl HttpNegotiateVtbl
= {
1058 HttpNegotiate_QueryInterface
,
1059 HttpNegotiate_AddRef
,
1060 HttpNegotiate_Release
,
1061 HttpNegotiate_BeginningTransaction
,
1062 HttpNegotiate_OnResponse
,
1063 HttpNegotiate_GetRootSecurityId
1066 static IHttpNegotiate2 HttpNegotiate
= { &HttpNegotiateVtbl
};
1068 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
1070 ok(0, "unexpected call\n");
1071 return E_NOINTERFACE
;
1074 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
1079 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
1084 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
,
1085 REFGUID guidService
, REFIID riid
, void **ppv
)
1087 if(IsEqualGUID(&IID_IAuthenticate
, guidService
)) {
1088 CHECK_EXPECT(QueryService_IAuthenticate
);
1092 if(IsEqualGUID(&IID_IInternetProtocol
, guidService
)) {
1093 CHECK_EXPECT2(QueryService_IInternetProtocol
);
1097 if(IsEqualGUID(&IID_IInternetBindInfo
, guidService
)) {
1098 CHECK_EXPECT(QueryService_IInternetBindInfo
);
1102 ok(0, "unexpected service %s\n", debugstr_guid(guidService
));
1103 return E_NOINTERFACE
;
1106 static IServiceProviderVtbl ServiceProviderVtbl
= {
1107 ServiceProvider_QueryInterface
,
1108 ServiceProvider_AddRef
,
1109 ServiceProvider_Release
,
1110 ServiceProvider_QueryService
1113 static IServiceProvider ServiceProvider
= { &ServiceProviderVtbl
};
1115 static IBindStatusCallback objbsc
;
1117 static HRESULT WINAPI
statusclb_QueryInterface(IBindStatusCallback
*iface
, REFIID riid
, void **ppv
)
1119 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1121 if(IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
1122 CHECK_EXPECT2(QueryInterface_IInternetProtocol
);
1123 if(emulate_protocol
) {
1127 return E_NOINTERFACE
;
1130 else if (IsEqualGUID(&IID_IServiceProvider
, riid
))
1132 CHECK_EXPECT2(QueryInterface_IServiceProvider
);
1133 *ppv
= &ServiceProvider
;
1136 else if (IsEqualGUID(&IID_IHttpNegotiate
, riid
))
1138 CHECK_EXPECT(QueryInterface_IHttpNegotiate
);
1139 *ppv
= &HttpNegotiate
;
1142 else if (IsEqualGUID(&IID_IHttpNegotiate2
, riid
))
1144 CHECK_EXPECT(QueryInterface_IHttpNegotiate2
);
1145 *ppv
= &HttpNegotiate
;
1148 else if (IsEqualGUID(&IID_IAuthenticate
, riid
))
1150 CHECK_EXPECT(QueryInterface_IAuthenticate
);
1151 return E_NOINTERFACE
;
1153 else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
))
1155 CHECK_EXPECT2(QueryInterface_IBindStatusCallback
);
1159 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder
, riid
))
1161 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder
);
1162 return E_NOINTERFACE
;
1164 else if(IsEqualGUID(&IID_IInternetBindInfo
, riid
))
1167 CHECK_EXPECT2(QueryInterface_IInternetBindInfo
);
1171 ok(0, "unexpected interface %s\n", debugstr_guid(riid
));
1174 return E_NOINTERFACE
;
1177 static ULONG WINAPI
statusclb_AddRef(IBindStatusCallback
*iface
)
1182 static ULONG WINAPI
statusclb_Release(IBindStatusCallback
*iface
)
1187 static HRESULT WINAPI
statusclb_OnStartBinding(IBindStatusCallback
*iface
, DWORD dwReserved
,
1190 IWinInetHttpInfo
*http_info
;
1194 if(iface
== &objbsc
)
1195 CHECK_EXPECT(Obj_OnStartBinding
);
1197 CHECK_EXPECT(OnStartBinding
);
1199 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1201 ok(pib
!= NULL
, "pib should not be NULL\n");
1202 ok(dwReserved
== 0xff, "dwReserved=%x\n", dwReserved
);
1204 if(pib
== (void*)0xdeadbeef)
1207 current_binding
= pib
;
1209 hres
= IBinding_QueryInterface(pib
, &IID_IMoniker
, (void**)&mon
);
1210 ok(hres
== E_NOINTERFACE
, "IBinding should not have IMoniker interface\n");
1212 IMoniker_Release(mon
);
1214 hres
= IBinding_QueryInterface(pib
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
1215 ok(hres
== E_NOINTERFACE
, "Could not get IID_IWinInetHttpInfo: %08x\n", hres
);
1220 static HRESULT WINAPI
statusclb_GetPriority(IBindStatusCallback
*iface
, LONG
*pnPriority
)
1222 ok(0, "unexpected call\n");
1226 static HRESULT WINAPI
statusclb_OnLowResource(IBindStatusCallback
*iface
, DWORD reserved
)
1228 ok(0, "unexpected call\n");
1232 static HRESULT WINAPI
statusclb_OnProgress(IBindStatusCallback
*iface
, ULONG ulProgress
,
1233 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
1235 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1237 switch(ulStatusCode
) {
1238 case BINDSTATUS_FINDINGRESOURCE
:
1239 if(iface
== &objbsc
)
1240 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
1241 else if(test_protocol
== FTP_TEST
)
1242 todo_wine
CHECK_EXPECT(OnProgress_FINDINGRESOURCE
);
1244 CHECK_EXPECT(OnProgress_FINDINGRESOURCE
);
1245 if((bindf
& BINDF_ASYNCHRONOUS
) && emulate_protocol
)
1246 SetEvent(complete_event
);
1248 case BINDSTATUS_CONNECTING
:
1249 if(iface
== &objbsc
)
1250 CHECK_EXPECT(Obj_OnProgress_CONNECTING
);
1251 else if(test_protocol
== FTP_TEST
)
1252 todo_wine
CHECK_EXPECT(OnProgress_CONNECTING
);
1254 CHECK_EXPECT(OnProgress_CONNECTING
);
1255 if((bindf
& BINDF_ASYNCHRONOUS
) && emulate_protocol
)
1256 SetEvent(complete_event
);
1258 case BINDSTATUS_SENDINGREQUEST
:
1259 if(iface
== &objbsc
)
1260 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
1261 else if(test_protocol
== FTP_TEST
)
1262 CHECK_EXPECT2(OnProgress_SENDINGREQUEST
);
1264 CHECK_EXPECT(OnProgress_SENDINGREQUEST
);
1265 if((bindf
& BINDF_ASYNCHRONOUS
) && emulate_protocol
)
1266 SetEvent(complete_event
);
1268 case BINDSTATUS_MIMETYPEAVAILABLE
:
1269 if(iface
== &objbsc
)
1270 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
1272 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
1274 ok(download_state
== BEFORE_DOWNLOAD
, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1276 WideCharToMultiByte(CP_ACP
, 0, szStatusText
, -1, mime_type
, sizeof(mime_type
)-1, NULL
, NULL
);
1278 case BINDSTATUS_BEGINDOWNLOADDATA
:
1279 if(iface
== &objbsc
)
1280 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
1282 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
1283 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1288 ok(!lstrcmpW(szStatusText
, urls
[test_protocol
]), "wrong szStatusText %s\n", debugstr_w(szStatusText
));
1292 ok(download_state
== BEFORE_DOWNLOAD
, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1294 download_state
= DOWNLOADING
;
1296 case BINDSTATUS_DOWNLOADINGDATA
:
1297 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA
);
1298 ok(iface
!= &objbsc
, "unexpected call\n");
1299 ok(download_state
== DOWNLOADING
, "Download state was %d, expected DOWNLOADING\n",
1302 case BINDSTATUS_ENDDOWNLOADDATA
:
1303 if(iface
== &objbsc
)
1304 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
1306 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA
);
1307 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1312 ok(!lstrcmpW(szStatusText
, urls
[test_protocol
]), "wrong szStatusText %s\n", debugstr_w(szStatusText
));
1315 ok(download_state
== DOWNLOADING
, "Download state was %d, expected DOWNLOADING\n",
1317 download_state
= END_DOWNLOAD
;
1319 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
1320 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
) {
1321 if(iface
== &objbsc
)
1322 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
1324 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
1326 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
1327 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
1330 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1331 if(szStatusText
&& test_protocol
== FILE_TEST
)
1332 ok(!lstrcmpW(file_url
+8, szStatusText
), "wrong szStatusText %s\n", debugstr_w(szStatusText
));
1334 case BINDSTATUS_CLASSIDAVAILABLE
:
1338 if(iface
!= &objbsc
)
1339 ok(0, "unexpected call\n");
1340 else if(1||emulate_protocol
)
1341 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
1343 todo_wine
CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
1344 hr
= CLSIDFromString((LPOLESTR
)szStatusText
, &clsid
);
1345 ok(hr
== S_OK
, "CLSIDFromString failed with error 0x%08x\n", hr
);
1346 ok(IsEqualCLSID(&clsid
, &CLSID_HTMLDocument
),
1347 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid
));
1350 case BINDSTATUS_BEGINSYNCOPERATION
:
1351 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
1352 if(iface
!= &objbsc
)
1353 ok(0, "unexpected call\n");
1354 ok(szStatusText
== NULL
, "Expected szStatusText to be NULL\n");
1356 case BINDSTATUS_ENDSYNCOPERATION
:
1357 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
1358 if(iface
!= &objbsc
)
1359 ok(0, "unexpected call\n");
1360 ok(szStatusText
== NULL
, "Expected szStatusText to be NULL\n");
1362 case BINDSTATUS_PROXYDETECTING
:
1363 trace("BINDSTATUS_PROXYDETECTING\n");
1365 case BINDSTATUS_COOKIE_SENT
:
1366 trace("BINDSTATUS_COOKIE_SENT\n");
1369 ok(0, "unexpected code %d\n", ulStatusCode
);
1372 if(current_binding
) {
1373 IWinInetHttpInfo
*http_info
;
1376 hres
= IBinding_QueryInterface(current_binding
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
1377 if(!emulate_protocol
&& test_protocol
!= FILE_TEST
&& is_urlmon_protocol(test_protocol
))
1378 ok(hres
== S_OK
, "Could not get IWinInetHttpInfo iface: %08x\n", hres
);
1380 ok(hres
== E_NOINTERFACE
,
1381 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres
);
1383 IWinInetHttpInfo_Release(http_info
);
1389 static HRESULT WINAPI
statusclb_OnStopBinding(IBindStatusCallback
*iface
, HRESULT hresult
, LPCWSTR szError
)
1391 if(iface
== &objbsc
) {
1392 CHECK_EXPECT(Obj_OnStopBinding
);
1393 stopped_obj_binding
= TRUE
;
1395 CHECK_EXPECT(OnStopBinding
);
1396 stopped_binding
= TRUE
;
1399 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1401 /* ignore DNS failure */
1402 if (hresult
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
1406 ok(SUCCEEDED(hresult
), "binding failed: %08x\n", hresult
);
1408 ok(hresult
== binding_hres
, "binding failed: %08x, expected %08x\n", hresult
, binding_hres
);
1409 ok(szError
== NULL
, "szError should be NULL\n");
1411 if((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) && emulate_protocol
) {
1412 SetEvent(complete_event
);
1413 if(iface
!= &objbsc
)
1414 WaitForSingleObject(complete_event2
, INFINITE
);
1420 static HRESULT WINAPI
statusclb_GetBindInfo(IBindStatusCallback
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
1424 if(iface
== &objbsc
)
1425 CHECK_EXPECT(Obj_GetBindInfo
);
1427 CHECK_EXPECT(GetBindInfo
);
1429 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1432 cbSize
= pbindinfo
->cbSize
;
1433 memset(pbindinfo
, 0, cbSize
);
1434 pbindinfo
->cbSize
= cbSize
;
1439 static HRESULT WINAPI
statusclb_OnDataAvailable(IBindStatusCallback
*iface
, DWORD grfBSCF
,
1440 DWORD dwSize
, FORMATETC
* pformatetc
, STGMEDIUM
* pstgmed
)
1447 if(iface
== &objbsc
)
1448 ok(0, "unexpected call\n");
1450 CHECK_EXPECT2(OnDataAvailable
);
1452 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1454 ok(download_state
== DOWNLOADING
|| download_state
== END_DOWNLOAD
,
1455 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1457 data_available
= TRUE
;
1459 ok(pformatetc
!= NULL
, "pformatetx == NULL\n");
1463 ok(GetClipboardFormatName(pformatetc
->cfFormat
, clipfmt
, sizeof(clipfmt
)-1),
1464 "GetClipboardFormatName failed, error %d\n", GetLastError());
1465 ok(!lstrcmp(clipfmt
, mime_type
), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1466 pformatetc
->cfFormat
, clipfmt
, mime_type
);
1468 ok(pformatetc
->cfFormat
== 0, "clipformat=%x\n", pformatetc
->cfFormat
);
1470 ok(pformatetc
->ptd
== NULL
, "ptd = %p\n", pformatetc
->ptd
);
1471 ok(pformatetc
->dwAspect
== 1, "dwAspect=%u\n", pformatetc
->dwAspect
);
1472 ok(pformatetc
->lindex
== -1, "lindex=%d\n", pformatetc
->lindex
);
1473 ok(pformatetc
->tymed
== tymed
, "tymed=%u, expected %u\n", pformatetc
->tymed
, tymed
);
1476 ok(pstgmed
!= NULL
, "stgmeg == NULL\n");
1477 ok(pstgmed
->tymed
== tymed
, "tymed=%u, expected %u\n", pstgmed
->tymed
, tymed
);
1478 ok(pstgmed
->pUnkForRelease
!= NULL
, "pUnkForRelease == NULL\n");
1480 switch(pstgmed
->tymed
) {
1482 if(grfBSCF
& BSCF_FIRSTDATANOTIFICATION
) {
1483 hres
= IStream_Write(U(*pstgmed
).pstm
, buf
, 10, NULL
);
1484 ok(hres
== STG_E_ACCESSDENIED
,
1485 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres
);
1487 hres
= IStream_Commit(U(*pstgmed
).pstm
, 0);
1488 ok(hres
== E_NOTIMPL
, "Commit failed: %08x, expected E_NOTIMPL\n", hres
);
1490 hres
= IStream_Revert(U(*pstgmed
).pstm
);
1491 ok(hres
== E_NOTIMPL
, "Revert failed: %08x, expected E_NOTIMPL\n", hres
);
1494 ok(U(*pstgmed
).pstm
!= NULL
, "U(*pstgmed).pstm == NULL\n");
1495 do hres
= IStream_Read(U(*pstgmed
).pstm
, buf
, 512, &readed
);
1496 while(hres
== S_OK
);
1497 ok(hres
== S_FALSE
|| hres
== E_PENDING
, "IStream_Read returned %08x\n", hres
);
1501 if(test_protocol
== FILE_TEST
)
1502 ok(!lstrcmpW(pstgmed
->u
.lpszFileName
, INDEX_HTML
+7),
1503 "unexpected file name %s\n", debugstr_w(pstgmed
->u
.lpszFileName
));
1504 else if(emulate_protocol
)
1505 ok(!lstrcmpW(pstgmed
->u
.lpszFileName
, cache_fileW
),
1506 "unexpected file name %s\n", debugstr_w(pstgmed
->u
.lpszFileName
));
1508 ok(pstgmed
->u
.lpszFileName
!= NULL
, "lpszFileName == NULL\n");
1511 if((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
1512 && emulate_protocol
&& prot_state
< 4 && (!bind_to_object
|| prot_state
> 1))
1513 SetEvent(complete_event
);
1518 static HRESULT WINAPI
statusclb_OnObjectAvailable(IBindStatusCallback
*iface
, REFIID riid
, IUnknown
*punk
)
1520 CHECK_EXPECT(OnObjectAvailable
);
1522 if(iface
!= &objbsc
)
1523 ok(0, "unexpected call\n");
1525 ok(IsEqualGUID(&IID_IUnknown
, riid
), "riid = %s\n", debugstr_guid(riid
));
1526 ok(punk
!= NULL
, "punk == NULL\n");
1531 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
1532 statusclb_QueryInterface
,
1535 statusclb_OnStartBinding
,
1536 statusclb_GetPriority
,
1537 statusclb_OnLowResource
,
1538 statusclb_OnProgress
,
1539 statusclb_OnStopBinding
,
1540 statusclb_GetBindInfo
,
1541 statusclb_OnDataAvailable
,
1542 statusclb_OnObjectAvailable
1545 static IBindStatusCallback bsc
= { &BindStatusCallbackVtbl
};
1546 static IBindStatusCallback objbsc
= { &BindStatusCallbackVtbl
};
1548 static HRESULT WINAPI
MonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
1551 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1552 return E_NOINTERFACE
;
1555 static ULONG WINAPI
MonikerProp_AddRef(IMonikerProp
*iface
)
1560 static ULONG WINAPI
MonikerProp_Release(IMonikerProp
*iface
)
1565 static HRESULT WINAPI
MonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
1569 CHECK_EXPECT(PutProperty_MIMETYPEPROP
);
1570 ok(!lstrcmpW(val
, wszTextHtml
), "val = %s\n", debugstr_w(val
));
1573 CHECK_EXPECT(PutProperty_CLASSIDPROP
);
1582 static const IMonikerPropVtbl MonikerPropVtbl
= {
1583 MonikerProp_QueryInterface
,
1585 MonikerProp_Release
,
1586 MonikerProp_PutProperty
1589 static IMonikerProp MonikerProp
= { &MonikerPropVtbl
};
1591 static HRESULT WINAPI
PersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
1595 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IPersistMoniker
, riid
))
1597 else if(IsEqualGUID(&IID_IMonikerProp
, riid
))
1598 *ppv
= &MonikerProp
;
1603 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1604 return E_NOINTERFACE
;
1607 static ULONG WINAPI
PersistMoniker_AddRef(IPersistMoniker
*iface
)
1612 static ULONG WINAPI
PersistMoniker_Release(IPersistMoniker
*iface
)
1617 static HRESULT WINAPI
PersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
1619 ok(0, "unexpected call\n");
1623 static HRESULT WINAPI
PersistMoniker_IsDirty(IPersistMoniker
*iface
)
1625 ok(0, "unexpected call\n");
1629 static HRESULT WINAPI
PersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
1630 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
1635 static WCHAR cbinding_contextW
[] =
1636 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1639 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1641 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
1642 ok(!fFullyAvailable
, "fFulyAvailable = %x\n", fFullyAvailable
);
1644 ok(fFullyAvailable
, "fFulyAvailable = %x\n", fFullyAvailable
);
1645 ok(pimkName
!= NULL
, "pimkName == NULL\n");
1646 ok(pibc
!= NULL
, "pibc == NULL\n");
1647 ok(grfMode
== 0x12, "grfMode = %x\n", grfMode
);
1649 hres
= IBindCtx_GetObjectParam(pibc
, cbinding_contextW
, &unk
);
1650 ok(hres
== S_OK
, "GetObjectParam(CBinding Context) failed: %08x\n", hres
);
1651 if(SUCCEEDED(hres
)) {
1654 hres
= IUnknown_QueryInterface(unk
, &IID_IBinding
, (void**)&binding
);
1655 ok(hres
== S_OK
, "Could not get IBinding: %08x\n", hres
);
1657 IBinding_Release(binding
);
1658 IUnknown_Release(unk
);
1661 SET_EXPECT(QueryInterface_IServiceProvider
);
1662 hres
= RegisterBindStatusCallback(pibc
, &bsc
, NULL
, 0);
1663 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
1664 CHECK_CALLED(QueryInterface_IServiceProvider
);
1666 SET_EXPECT(GetBindInfo
);
1667 SET_EXPECT(OnStartBinding
);
1668 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
1669 if(test_protocol
== FILE_TEST
)
1670 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
1671 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
1672 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
1673 SET_EXPECT(LockRequest
);
1674 SET_EXPECT(OnDataAvailable
);
1675 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
1676 SET_EXPECT(OnStopBinding
);
1678 hres
= IMoniker_BindToStorage(pimkName
, pibc
, NULL
, &IID_IStream
, (void**)&unk
);
1679 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
1681 CHECK_CALLED(GetBindInfo
);
1682 CHECK_CALLED(OnStartBinding
);
1683 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
1684 if(test_protocol
== FILE_TEST
)
1685 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
1686 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
1687 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
1688 CHECK_CALLED(LockRequest
);
1689 CHECK_CALLED(OnDataAvailable
);
1690 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
1691 CHECK_CALLED(OnStopBinding
);
1694 IUnknown_Release(unk
);
1699 static HRESULT WINAPI
PersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pbc
, BOOL fRemember
)
1701 ok(0, "unexpected call\n");
1705 static HRESULT WINAPI
PersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
1707 ok(0, "unexpected call\n");
1711 static HRESULT WINAPI
PersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**pimkName
)
1713 ok(0, "unexpected call\n");
1717 static const IPersistMonikerVtbl PersistMonikerVtbl
= {
1718 PersistMoniker_QueryInterface
,
1719 PersistMoniker_AddRef
,
1720 PersistMoniker_Release
,
1721 PersistMoniker_GetClassID
,
1722 PersistMoniker_IsDirty
,
1723 PersistMoniker_Load
,
1724 PersistMoniker_Save
,
1725 PersistMoniker_SaveCompleted
,
1726 PersistMoniker_GetCurMoniker
1729 static IPersistMoniker PersistMoniker
= { &PersistMonikerVtbl
};
1731 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1735 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
1740 if(IsEqualGUID(&IID_IMarshal
, riid
))
1741 return E_NOINTERFACE
;
1742 if(IsEqualGUID(&CLSID_IdentityUnmarshal
, riid
))
1743 return E_NOINTERFACE
;
1745 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1749 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1754 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1759 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
1761 CHECK_EXPECT(CreateInstance
);
1762 ok(!outer
, "outer = %p\n", outer
);
1763 ok(IsEqualGUID(&IID_IUnknown
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1764 *ppv
= &PersistMoniker
;
1768 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1770 ok(0, "unexpected call\n");
1774 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1775 ClassFactory_QueryInterface
,
1776 ClassFactory_AddRef
,
1777 ClassFactory_Release
,
1778 ClassFactory_CreateInstance
,
1779 ClassFactory_LockServer
1782 static IClassFactory mime_cf
= { &ClassFactoryVtbl
};
1784 static void test_CreateAsyncBindCtx(void)
1786 IBindCtx
*bctx
= (IBindCtx
*)0x0ff00ff0;
1792 hres
= CreateAsyncBindCtx(0, NULL
, NULL
, &bctx
);
1793 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres
);
1794 ok(bctx
== (IBindCtx
*)0x0ff00ff0, "bctx should not be changed\n");
1796 hres
= CreateAsyncBindCtx(0, NULL
, NULL
, NULL
);
1797 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres
);
1799 SET_EXPECT(QueryInterface_IServiceProvider
);
1800 hres
= CreateAsyncBindCtx(0, &bsc
, NULL
, &bctx
);
1801 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n", hres
);
1802 CHECK_CALLED(QueryInterface_IServiceProvider
);
1804 bindopts
.cbStruct
= sizeof(bindopts
);
1805 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
1806 ok(SUCCEEDED(hres
), "IBindCtx_GetBindOptions failed: %08x\n", hres
);
1807 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
1808 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
1809 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
1810 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1812 ok(bindopts
.dwTickCountDeadline
== 0,
1813 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
1815 hres
= IBindCtx_QueryInterface(bctx
, &IID_IAsyncBindCtx
, (void**)&unk
);
1816 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres
);
1818 IUnknown_Release(unk
);
1820 ref
= IBindCtx_Release(bctx
);
1821 ok(ref
== 0, "bctx should be destroyed here\n");
1824 static void test_CreateAsyncBindCtxEx(void)
1826 IBindCtx
*bctx
= NULL
, *bctx2
= NULL
, *bctx_arg
= NULL
;
1831 static WCHAR testW
[] = {'t','e','s','t',0};
1833 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, NULL
, 0);
1834 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres
);
1836 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
1837 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1839 if(SUCCEEDED(hres
)) {
1840 bindopts
.cbStruct
= sizeof(bindopts
);
1841 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
1842 ok(SUCCEEDED(hres
), "IBindCtx_GetBindOptions failed: %08x\n", hres
);
1843 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
1844 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
1845 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
1846 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1848 ok(bindopts
.dwTickCountDeadline
== 0,
1849 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
1851 IBindCtx_Release(bctx
);
1854 CreateBindCtx(0, &bctx_arg
);
1855 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
1856 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1858 if(SUCCEEDED(hres
)) {
1859 bindopts
.cbStruct
= sizeof(bindopts
);
1860 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
1861 ok(SUCCEEDED(hres
), "IBindCtx_GetBindOptions failed: %08x\n", hres
);
1862 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
1863 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
1864 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
1865 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1867 ok(bindopts
.dwTickCountDeadline
== 0,
1868 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
1870 IBindCtx_Release(bctx
);
1873 IBindCtx_Release(bctx_arg
);
1875 SET_EXPECT(QueryInterface_IServiceProvider
);
1876 hres
= CreateAsyncBindCtxEx(NULL
, 0, &bsc
, NULL
, &bctx
, 0);
1877 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1878 CHECK_CALLED(QueryInterface_IServiceProvider
);
1880 hres
= IBindCtx_QueryInterface(bctx
, &IID_IAsyncBindCtx
, (void**)&unk
);
1881 ok(hres
== S_OK
, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres
);
1883 IUnknown_Release(unk
);
1885 IBindCtx_Release(bctx
);
1887 hres
= CreateBindCtx(0, &bctx2
);
1888 ok(hres
== S_OK
, "CreateBindCtx failed: %08x\n", hres
);
1890 hres
= CreateAsyncBindCtxEx(bctx2
, 0, NULL
, NULL
, &bctx
, 0);
1891 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1893 hres
= IBindCtx_RegisterObjectParam(bctx2
, testW
, (IUnknown
*)&Protocol
);
1894 ok(hres
== S_OK
, "RegisterObjectParam failed: %08x\n", hres
);
1896 hres
= IBindCtx_GetObjectParam(bctx
, testW
, &unk
);
1897 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
1898 ok(unk
== (IUnknown
*)&Protocol
, "unexpected unk %p\n", unk
);
1900 IBindCtx_Release(bctx
);
1901 IBindCtx_Release(bctx2
);
1904 static BOOL
test_bscholder(IBindStatusCallback
*holder
)
1906 IServiceProvider
*serv_prov
;
1907 IHttpNegotiate
*http_negotiate
, *http_negotiate_serv
;
1908 IHttpNegotiate2
*http_negotiate2
, *http_negotiate2_serv
;
1909 IAuthenticate
*authenticate
, *authenticate_serv
;
1910 IInternetProtocol
*protocol
;
1911 BINDINFO bindinfo
= {sizeof(bindinfo
)};
1917 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IServiceProvider
, (void**)&serv_prov
);
1918 ok(hres
== S_OK
, "Could not get IServiceProvider interface: %08x\n", hres
);
1921 SET_EXPECT(GetBindInfo
);
1922 hres
= IBindStatusCallback_GetBindInfo(holder
, &dw
, &bindinfo
);
1923 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
1924 CHECK_CALLED(GetBindInfo
);
1926 SET_EXPECT(OnStartBinding
);
1927 hres
= IBindStatusCallback_OnStartBinding(holder
, 0, (void*)0xdeadbeef);
1928 ok(hres
== S_OK
, "OnStartBinding failed: %08x\n", hres
);
1929 CHECK_CALLED(OnStartBinding
);
1931 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1932 ok(hres
== S_OK
, "Could not get IHttpNegotiate interface: %08x\n", hres
);
1934 wstr
= (void*)0xdeadbeef;
1935 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, urls
[test_protocol
], (void*)0xdeadbeef, 0xff, &wstr
);
1936 ok(hres
== S_OK
, "BeginningTransaction failed: %08x\n", hres
);
1937 ok(wstr
== NULL
, "wstr = %p\n", wstr
);
1939 SET_EXPECT(QueryInterface_IHttpNegotiate
);
1940 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate
, &IID_IHttpNegotiate
,
1941 (void**)&http_negotiate_serv
);
1942 ok(hres
== S_OK
, "Could not get IHttpNegotiate service: %08x\n", hres
);
1943 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
1945 ok(http_negotiate
== http_negotiate_serv
, "http_negotiate != http_negotiate_serv\n");
1947 wstr
= (void*)0xdeadbeef;
1948 SET_EXPECT(BeginningTransaction
);
1949 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate_serv
, urls
[test_protocol
], emptyW
, 0, &wstr
);
1950 CHECK_CALLED(BeginningTransaction
);
1951 ok(hres
== S_OK
, "BeginningTransaction failed: %08x\n", hres
);
1952 ok(wstr
== NULL
, "wstr = %p\n", wstr
);
1954 IHttpNegotiate_Release(http_negotiate_serv
);
1956 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate
, &IID_IHttpNegotiate
,
1957 (void**)&http_negotiate_serv
);
1958 ok(hres
== S_OK
, "Could not get IHttpNegotiate service: %08x\n", hres
);
1959 ok(http_negotiate
== http_negotiate_serv
, "http_negotiate != http_negotiate_serv\n");
1960 IHttpNegotiate_Release(http_negotiate_serv
);
1962 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
1963 if(SUCCEEDED(hres
)) {
1964 have_IHttpNegotiate2
= TRUE
;
1965 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1966 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x\n", hres
);
1968 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
1969 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate2
, &IID_IHttpNegotiate2
,
1970 (void**)&http_negotiate2_serv
);
1971 ok(hres
== S_OK
, "Could not get IHttpNegotiate2 service: %08x\n", hres
);
1972 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
1973 ok(http_negotiate2
== http_negotiate2_serv
, "http_negotiate != http_negotiate_serv\n");
1975 SET_EXPECT(GetRootSecurityId
);
1976 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1977 ok(hres
== E_NOTIMPL
, "GetRootSecurityId failed: %08x\n", hres
);
1978 CHECK_CALLED(GetRootSecurityId
);
1980 IHttpNegotiate_Release(http_negotiate2_serv
);
1981 IHttpNegotiate_Release(http_negotiate2
);
1983 skip("Could not get IHttpNegotiate2\n");
1987 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
1988 hres
= IBindStatusCallback_OnProgress(holder
, 0, 0, BINDSTATUS_FINDINGRESOURCE
, NULL
);
1989 ok(hres
== S_OK
, "OnProgress failed: %08x\n", hres
);
1990 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
1992 SET_EXPECT(OnResponse
);
1993 wstr
= (void*)0xdeadbeef;
1994 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, emptyW
, NULL
, NULL
);
1995 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
1996 CHECK_CALLED(OnResponse
);
1998 IHttpNegotiate_Release(http_negotiate
);
2000 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IAuthenticate
, (void**)&authenticate
);
2001 ok(hres
== S_OK
, "Could not get IAuthenticate interface: %08x\n", hres
);
2003 SET_EXPECT(QueryInterface_IAuthenticate
);
2004 SET_EXPECT(QueryService_IAuthenticate
);
2005 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IAuthenticate
, &IID_IAuthenticate
,
2006 (void**)&authenticate_serv
);
2007 ok(hres
== S_OK
, "Could not get IAuthenticate service: %08x\n", hres
);
2008 CHECK_CALLED(QueryInterface_IAuthenticate
);
2009 CHECK_CALLED(QueryService_IAuthenticate
);
2010 ok(authenticate
== authenticate_serv
, "authenticate != authenticate_serv\n");
2011 IAuthenticate_Release(authenticate_serv
);
2013 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IAuthenticate
, &IID_IAuthenticate
,
2014 (void**)&authenticate_serv
);
2015 ok(hres
== S_OK
, "Could not get IAuthenticate service: %08x\n", hres
);
2016 ok(authenticate
== authenticate_serv
, "authenticate != authenticate_serv\n");
2018 IAuthenticate_Release(authenticate
);
2019 IAuthenticate_Release(authenticate_serv
);
2021 SET_EXPECT(OnStopBinding
);
2022 hres
= IBindStatusCallback_OnStopBinding(holder
, S_OK
, NULL
);
2023 ok(hres
== S_OK
, "OnStopBinding failed: %08x\n", hres
);
2024 CHECK_CALLED(OnStopBinding
);
2026 SET_EXPECT(QueryInterface_IInternetProtocol
);
2027 SET_EXPECT(QueryService_IInternetProtocol
);
2028 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IInternetProtocol
, &IID_IInternetProtocol
,
2030 ok(hres
== E_NOINTERFACE
, "QueryService(IInternetProtocol) failed: %08x\n", hres
);
2031 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2032 CHECK_CALLED(QueryService_IInternetProtocol
);
2034 IServiceProvider_Release(serv_prov
);
2038 static BOOL
test_RegisterBindStatusCallback(void)
2040 IBindStatusCallback
*prevbsc
, *clb
;
2046 hres
= CreateBindCtx(0, &bindctx
);
2047 ok(hres
== S_OK
, "BindCtx failed: %08x\n", hres
);
2049 SET_EXPECT(QueryInterface_IServiceProvider
);
2051 hres
= IBindCtx_RegisterObjectParam(bindctx
, BSCBHolder
, (IUnknown
*)&bsc
);
2052 ok(hres
== S_OK
, "RegisterObjectParam failed: %08x\n", hres
);
2054 SET_EXPECT(QueryInterface_IBindStatusCallback
);
2055 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder
);
2056 prevbsc
= (void*)0xdeadbeef;
2057 hres
= RegisterBindStatusCallback(bindctx
, &bsc
, &prevbsc
, 0);
2058 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
2059 ok(prevbsc
== &bsc
, "prevbsc=%p\n", prevbsc
);
2060 CHECK_CALLED(QueryInterface_IBindStatusCallback
);
2061 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder
);
2063 CHECK_CALLED(QueryInterface_IServiceProvider
);
2065 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
2066 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
2068 hres
= IUnknown_QueryInterface(unk
, &IID_IBindStatusCallback
, (void**)&clb
);
2069 IUnknown_Release(unk
);
2070 ok(hres
== S_OK
, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres
);
2071 ok(clb
!= &bsc
, "bsc == clb\n");
2073 if(!test_bscholder(clb
))
2076 IBindStatusCallback_Release(clb
);
2078 hres
= RevokeBindStatusCallback(bindctx
, &bsc
);
2079 ok(hres
== S_OK
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2081 unk
= (void*)0xdeadbeef;
2082 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
2083 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x\n", hres
);
2084 ok(unk
== NULL
, "unk != NULL\n");
2087 IUnknown_Release(unk
);
2089 hres
= RevokeBindStatusCallback(bindctx
, (void*)0xdeadbeef);
2090 ok(hres
== S_OK
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2092 hres
= RevokeBindStatusCallback(NULL
, (void*)0xdeadbeef);
2093 ok(hres
== E_INVALIDARG
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2095 hres
= RevokeBindStatusCallback(bindctx
, NULL
);
2096 ok(hres
== E_INVALIDARG
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2098 IBindCtx_Release(bindctx
);
2102 #define BINDTEST_EMULATE 1
2103 #define BINDTEST_TOOBJECT 2
2104 #define BINDTEST_FILEDWLAPI 4
2106 static void init_bind_test(int protocol
, DWORD flags
, DWORD t
)
2108 test_protocol
= protocol
;
2109 emulate_protocol
= (flags
& BINDTEST_EMULATE
) != 0;
2110 download_state
= BEFORE_DOWNLOAD
;
2111 stopped_binding
= FALSE
;
2112 stopped_obj_binding
= FALSE
;
2113 data_available
= FALSE
;
2115 binding_hres
= S_OK
;
2116 bind_to_object
= (flags
& BINDTEST_TOOBJECT
) != 0;
2118 filedwl_api
= (flags
& BINDTEST_FILEDWLAPI
) != 0;
2121 static void test_BindToStorage(int protocol
, BOOL emul
, DWORD t
)
2125 LPOLESTR display_name
;
2128 IBindStatusCallback
*previousclb
;
2129 IUnknown
*unk
= (IUnknown
*)0x00ff00ff;
2132 init_bind_test(protocol
, emul
? BINDTEST_EMULATE
: 0, t
);
2134 SET_EXPECT(QueryInterface_IServiceProvider
);
2135 hres
= CreateAsyncBindCtx(0, &bsc
, NULL
, &bctx
);
2136 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
2137 CHECK_CALLED(QueryInterface_IServiceProvider
);
2141 SET_EXPECT(QueryInterface_IServiceProvider
);
2142 hres
= RegisterBindStatusCallback(bctx
, &bsc
, &previousclb
, 0);
2143 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
2144 ok(previousclb
== &bsc
, "previousclb(%p) != sclb(%p)\n", previousclb
, &bsc
);
2145 CHECK_CALLED(QueryInterface_IServiceProvider
);
2147 IBindStatusCallback_Release(previousclb
);
2149 hres
= CreateURLMoniker(NULL
, test_protocol
== FILE_TEST
? file_url
: urls
[test_protocol
], &mon
);
2150 ok(SUCCEEDED(hres
), "failed to create moniker: %08x\n", hres
);
2152 IBindCtx_Release(bctx
);
2156 hres
= IMoniker_QueryInterface(mon
, &IID_IBinding
, (void**)&bind
);
2157 ok(hres
== E_NOINTERFACE
, "IMoniker should not have IBinding interface\n");
2159 IBinding_Release(bind
);
2161 hres
= IMoniker_GetDisplayName(mon
, bctx
, NULL
, &display_name
);
2162 ok(hres
== S_OK
, "GetDisplayName failed %08x\n", hres
);
2163 ok(!lstrcmpW(display_name
, urls
[test_protocol
]),
2164 "GetDisplayName got wrong name %s\n", debugstr_w(display_name
));
2165 CoTaskMemFree(display_name
);
2167 if(tymed
== TYMED_FILE
&& (test_protocol
== ABOUT_TEST
|| test_protocol
== ITS_TEST
))
2168 binding_hres
= INET_E_DATA_NOT_AVAILABLE
;
2170 SET_EXPECT(GetBindInfo
);
2171 SET_EXPECT(QueryInterface_IInternetProtocol
);
2172 if(!emulate_protocol
)
2173 SET_EXPECT(QueryService_IInternetProtocol
);
2174 SET_EXPECT(OnStartBinding
);
2175 if(emulate_protocol
) {
2176 if(is_urlmon_protocol(test_protocol
))
2177 SET_EXPECT(SetPriority
);
2179 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2180 SET_EXPECT(Terminate
);
2181 if(tymed
!= TYMED_FILE
|| (test_protocol
!= ABOUT_TEST
&& test_protocol
!= ITS_TEST
))
2182 SET_EXPECT(UnlockRequest
);
2184 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
2185 SET_EXPECT(QueryInterface_IInternetBindInfo
);
2186 SET_EXPECT(QueryService_IInternetBindInfo
);
2187 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2188 SET_EXPECT(BeginningTransaction
);
2189 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
2190 SET_EXPECT(GetRootSecurityId
);
2191 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
2192 SET_EXPECT(OnProgress_CONNECTING
);
2194 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FTP_TEST
2195 || test_protocol
== FILE_TEST
)
2196 SET_EXPECT(OnProgress_SENDINGREQUEST
);
2197 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2198 SET_EXPECT(OnResponse
);
2199 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
2200 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
2201 if(test_protocol
== FILE_TEST
)
2202 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
2203 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FTP_TEST
)
2204 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
2205 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
2206 if(tymed
!= TYMED_FILE
|| test_protocol
!= ABOUT_TEST
)
2207 SET_EXPECT(OnDataAvailable
);
2208 SET_EXPECT(OnStopBinding
);
2211 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, tymed
== TYMED_ISTREAM
? &IID_IStream
: &IID_IUnknown
, (void**)&unk
);
2212 if ((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2213 && hres
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
2215 skip("Network unreachable, skipping tests\n");
2219 if(((bindf
& BINDF_ASYNCHRONOUS
) && !data_available
)
2220 || (tymed
== TYMED_FILE
&& test_protocol
== FILE_TEST
)) {
2221 ok(hres
== MK_S_ASYNCHRONOUS
, "IMoniker_BindToStorage failed: %08x\n", hres
);
2222 ok(unk
== NULL
, "istr should be NULL\n");
2223 }else if(tymed
== TYMED_FILE
&& test_protocol
== ABOUT_TEST
) {
2224 ok(hres
== INET_E_DATA_NOT_AVAILABLE
,
2225 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres
);
2226 ok(unk
== NULL
, "istr should be NULL\n");
2228 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
2229 ok(unk
!= NULL
, "unk == NULL\n");
2232 IUnknown_Release(unk
);
2237 while((bindf
& BINDF_ASYNCHRONOUS
) &&
2238 !stopped_binding
&& GetMessage(&msg
,NULL
,0,0)) {
2239 TranslateMessage(&msg
);
2240 DispatchMessage(&msg
);
2243 CHECK_CALLED(GetBindInfo
);
2244 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2245 if(!emulate_protocol
)
2246 CHECK_CALLED(QueryService_IInternetProtocol
);
2247 CHECK_CALLED(OnStartBinding
);
2248 if(emulate_protocol
) {
2249 if(is_urlmon_protocol(test_protocol
))
2250 CHECK_CALLED(SetPriority
);
2251 CHECK_CALLED(Start
);
2252 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
2253 if(tymed
== TYMED_FILE
)
2255 CHECK_CALLED(Terminate
);
2257 if(tymed
!= TYMED_FILE
|| (test_protocol
!= ABOUT_TEST
&& test_protocol
!= ITS_TEST
))
2258 CHECK_CALLED(UnlockRequest
);
2260 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
2261 CLEAR_CALLED(QueryInterface_IInternetBindInfo
);
2262 CLEAR_CALLED(QueryService_IInternetBindInfo
);
2263 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
2264 CHECK_CALLED(BeginningTransaction
);
2265 if (have_IHttpNegotiate2
)
2267 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
2268 CHECK_CALLED(GetRootSecurityId
);
2270 if(http_is_first
|| test_protocol
== HTTPS_TEST
) {
2271 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
2272 CHECK_CALLED(OnProgress_CONNECTING
);
2274 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE
);
2275 /* IE7 does call this */
2276 CLEAR_CALLED(OnProgress_CONNECTING
);
2279 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
)
2280 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
2281 else if(test_protocol
== FTP_TEST
)
2282 todo_wine
CHECK_CALLED(OnProgress_SENDINGREQUEST
);
2283 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2284 CHECK_CALLED(OnResponse
);
2285 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
2286 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
2287 if(test_protocol
== FILE_TEST
)
2288 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
2289 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FTP_TEST
)
2290 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
2291 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
2292 if(tymed
!= TYMED_FILE
|| test_protocol
!= ABOUT_TEST
)
2293 CHECK_CALLED(OnDataAvailable
);
2294 CHECK_CALLED(OnStopBinding
);
2297 ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
2298 ok(IBindCtx_Release(bctx
) == 0, "bctx should be destroyed here\n");
2300 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2301 http_is_first
= FALSE
;
2304 static void test_BindToObject(int protocol
, BOOL emul
)
2308 LPOLESTR display_name
;
2312 IUnknown
*unk
= (IUnknown
*)0x00ff00ff;
2315 init_bind_test(protocol
, BINDTEST_TOOBJECT
| (emul
? BINDTEST_EMULATE
: 0), TYMED_ISTREAM
);
2318 CoRegisterClassObject(&CLSID_HTMLDocument
, (IUnknown
*)&mime_cf
,
2319 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, ®id
);
2321 SET_EXPECT(QueryInterface_IServiceProvider
);
2322 hres
= CreateAsyncBindCtx(0, &objbsc
, NULL
, &bctx
);
2323 ok(SUCCEEDED(hres
), "CreateAsyncBindCtx failed: %08x\n\n", hres
);
2324 CHECK_CALLED(QueryInterface_IServiceProvider
);
2328 hres
= CreateURLMoniker(NULL
, test_protocol
== FILE_TEST
? file_url
: urls
[test_protocol
], &mon
);
2329 ok(SUCCEEDED(hres
), "failed to create moniker: %08x\n", hres
);
2331 IBindCtx_Release(bctx
);
2335 hres
= IMoniker_QueryInterface(mon
, &IID_IBinding
, (void**)&bind
);
2336 ok(hres
== E_NOINTERFACE
, "IMoniker should not have IBinding interface\n");
2338 IBinding_Release(bind
);
2340 hres
= IMoniker_GetDisplayName(mon
, bctx
, NULL
, &display_name
);
2341 ok(hres
== S_OK
, "GetDisplayName failed %08x\n", hres
);
2342 ok(!lstrcmpW(display_name
, urls
[test_protocol
]), "GetDisplayName got wrong name\n");
2344 SET_EXPECT(Obj_GetBindInfo
);
2345 SET_EXPECT(QueryInterface_IInternetProtocol
);
2346 if(!emulate_protocol
)
2347 SET_EXPECT(QueryService_IInternetProtocol
);
2348 SET_EXPECT(Obj_OnStartBinding
);
2349 if(emulate_protocol
) {
2350 if(is_urlmon_protocol(test_protocol
))
2351 SET_EXPECT(SetPriority
);
2353 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2354 SET_EXPECT(Terminate
);
2355 if(test_protocol
== FILE_TEST
)
2356 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
2357 SET_EXPECT(UnlockRequest
);
2359 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
2360 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2361 SET_EXPECT(BeginningTransaction
);
2362 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
2363 SET_EXPECT(GetRootSecurityId
);
2364 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
2365 SET_EXPECT(Obj_OnProgress_CONNECTING
);
2367 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
)
2368 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
2369 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2370 SET_EXPECT(OnResponse
);
2371 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
2372 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
2373 if(test_protocol
== FILE_TEST
)
2374 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
2375 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2376 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
2377 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
2378 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
2379 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
2380 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
2381 SET_EXPECT(OnObjectAvailable
);
2382 SET_EXPECT(Obj_OnStopBinding
);
2385 hres
= IMoniker_BindToObject(mon
, bctx
, NULL
, &IID_IUnknown
, (void**)&unk
);
2387 if ((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2388 && hres
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
2390 skip( "Network unreachable, skipping tests\n" );
2394 /* no point testing the calls if binding didn't even work */
2395 if (FAILED(hres
)) return;
2397 if(bindf
& BINDF_ASYNCHRONOUS
) {
2398 ok(hres
== MK_S_ASYNCHRONOUS
, "IMoniker_BindToObject failed: %08x\n", hres
);
2399 ok(unk
== NULL
, "istr should be NULL\n");
2401 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
2402 ok(unk
!= NULL
, "unk == NULL\n");
2404 ok(unk
== (IUnknown
*)&PersistMoniker
, "unk != PersistMoniker\n");
2407 IUnknown_Release(unk
);
2409 while((bindf
& BINDF_ASYNCHRONOUS
) &&
2410 !((!emul
|| stopped_binding
) && stopped_obj_binding
) && GetMessage(&msg
,NULL
,0,0)) {
2411 TranslateMessage(&msg
);
2412 DispatchMessage(&msg
);
2415 CHECK_CALLED(Obj_GetBindInfo
);
2416 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2417 if(!emulate_protocol
)
2418 CHECK_CALLED(QueryService_IInternetProtocol
);
2419 CHECK_CALLED(Obj_OnStartBinding
);
2420 if(emulate_protocol
) {
2421 if(is_urlmon_protocol(test_protocol
))
2422 CHECK_CALLED(SetPriority
);
2423 CHECK_CALLED(Start
);
2424 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2425 CHECK_CALLED(Terminate
);
2426 if(test_protocol
== FILE_TEST
)
2427 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE
); /* not called in IE7 */
2428 CHECK_CALLED(UnlockRequest
);
2430 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
2431 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
2432 CHECK_CALLED(BeginningTransaction
);
2433 if (have_IHttpNegotiate2
)
2435 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
2436 CHECK_CALLED(GetRootSecurityId
);
2439 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
2440 CHECK_CALLED(Obj_OnProgress_CONNECTING
);
2442 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
2443 /* IE7 does call this */
2444 CLEAR_CALLED(Obj_OnProgress_CONNECTING
);
2447 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
) {
2448 if(urls
[test_protocol
] == SHORT_RESPONSE_URL
)
2449 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST
);
2451 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
2453 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2454 CHECK_CALLED(OnResponse
);
2455 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
2456 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
2457 if(test_protocol
== FILE_TEST
)
2458 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
2459 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2460 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
2461 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA
);
2462 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
2463 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
2464 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
2465 CHECK_CALLED(OnObjectAvailable
);
2466 CHECK_CALLED(Obj_OnStopBinding
);
2469 if(test_protocol
!= HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| emul
|| urls
[test_protocol
] == SHORT_RESPONSE_URL
) {
2470 ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
2471 ok(IBindCtx_Release(bctx
) == 0, "bctx should be destroyed here\n");
2473 todo_wine
ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
2475 if(bindf
& BINDF_ASYNCHRONOUS
)
2476 IBindCtx_Release(bctx
);
2478 todo_wine
ok(IBindCtx_Release(bctx
) == 0, "bctx should be destroyed here\n");
2482 CoRevokeClassObject(regid
);
2484 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2485 http_is_first
= FALSE
;
2488 static void test_URLDownloadToFile(DWORD prot
, BOOL emul
)
2493 init_bind_test(prot
, BINDTEST_FILEDWLAPI
| (emul
? BINDTEST_EMULATE
: 0), TYMED_FILE
);
2495 SET_EXPECT(GetBindInfo
);
2496 SET_EXPECT(QueryInterface_IInternetProtocol
);
2497 if(!emulate_protocol
) {
2498 SET_EXPECT(QueryInterface_IServiceProvider
);
2499 SET_EXPECT(QueryService_IInternetProtocol
);
2501 SET_EXPECT(OnStartBinding
);
2502 if(emulate_protocol
) {
2503 if(is_urlmon_protocol(test_protocol
))
2504 SET_EXPECT(SetPriority
);
2506 SET_EXPECT(UnlockRequest
);
2508 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
2509 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2510 SET_EXPECT(BeginningTransaction
);
2511 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
2512 SET_EXPECT(GetRootSecurityId
);
2514 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
)
2515 SET_EXPECT(OnProgress_SENDINGREQUEST
);
2516 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2517 SET_EXPECT(OnResponse
);
2518 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
2519 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
2520 if(test_protocol
== FILE_TEST
)
2521 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
2522 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2523 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
2524 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
2525 SET_EXPECT(OnStopBinding
);
2528 hres
= URLDownloadToFileW(NULL
, test_protocol
== FILE_TEST
? file_url
: urls
[test_protocol
], dwl_htmlW
, 0, &bsc
);
2529 ok(hres
== S_OK
, "URLDownloadToFile failed: %08x\n", hres
);
2531 CHECK_CALLED(GetBindInfo
);
2532 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2533 if(!emulate_protocol
) {
2534 CHECK_CALLED(QueryInterface_IServiceProvider
);
2535 CHECK_CALLED(QueryService_IInternetProtocol
);
2537 CHECK_CALLED(OnStartBinding
);
2538 if(emulate_protocol
) {
2539 if(is_urlmon_protocol(test_protocol
))
2540 CHECK_CALLED(SetPriority
);
2541 CHECK_CALLED(Start
);
2542 CHECK_CALLED(UnlockRequest
);
2544 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
2545 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
2546 CHECK_CALLED(BeginningTransaction
);
2547 if (have_IHttpNegotiate2
)
2549 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
2550 CHECK_CALLED(GetRootSecurityId
);
2553 if(test_protocol
== FILE_TEST
)
2554 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
2555 else if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2556 CLEAR_CALLED(OnProgress_SENDINGREQUEST
); /* not called by IE7 */
2557 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2558 CHECK_CALLED(OnResponse
);
2559 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
2560 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
2561 if(test_protocol
== FILE_TEST
)
2562 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
2563 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2564 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
2565 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
2566 CHECK_CALLED(OnStopBinding
);
2569 res
= DeleteFileA(dwl_htmlA
);
2570 ok(res
, "DeleteFile failed: %u\n", GetLastError());
2572 if(prot
!= FILE_TEST
|| emul
)
2575 hres
= URLDownloadToFileW(NULL
, urls
[test_protocol
], dwl_htmlW
, 0, NULL
);
2576 ok(hres
== S_OK
, "URLDownloadToFile failed: %08x\n", hres
);
2578 res
= DeleteFileA(dwl_htmlA
);
2579 ok(res
, "DeleteFile failed: %u\n", GetLastError());
2582 static void set_file_url(char *path
)
2584 CHAR file_urlA
[INTERNET_MAX_URL_LENGTH
];
2585 CHAR INDEX_HTMLA
[MAX_PATH
];
2587 lstrcpyA(file_urlA
, "file:///");
2588 lstrcatA(file_urlA
, path
);
2589 MultiByteToWideChar(CP_ACP
, 0, file_urlA
, -1, file_url
, INTERNET_MAX_URL_LENGTH
);
2591 lstrcpyA(INDEX_HTMLA
, "file://");
2592 lstrcatA(INDEX_HTMLA
, path
);
2593 MultiByteToWideChar(CP_ACP
, 0, INDEX_HTMLA
, -1, INDEX_HTML
, MAX_PATH
);
2596 static void create_file(void)
2600 CHAR path
[MAX_PATH
];
2602 static const char html_doc
[] = "<HTML></HTML>";
2604 file
= CreateFileA(wszIndexHtmlA
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
2605 FILE_ATTRIBUTE_NORMAL
, NULL
);
2606 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
2607 if(file
== INVALID_HANDLE_VALUE
)
2610 WriteFile(file
, html_doc
, sizeof(html_doc
)-1, &size
, NULL
);
2613 GetCurrentDirectoryA(MAX_PATH
, path
);
2614 lstrcatA(path
, "\\");
2615 lstrcatA(path
, wszIndexHtmlA
);
2619 static void test_ReportResult(HRESULT exhres
)
2621 IMoniker
*mon
= NULL
;
2622 IBindCtx
*bctx
= NULL
;
2623 IUnknown
*unk
= (void*)0xdeadbeef;
2626 init_bind_test(ABOUT_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
2627 binding_hres
= exhres
;
2629 hres
= CreateURLMoniker(NULL
, ABOUT_BLANK
, &mon
);
2630 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
2632 SET_EXPECT(QueryInterface_IServiceProvider
);
2633 hres
= CreateAsyncBindCtx(0, &bsc
, NULL
, &bctx
);
2634 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
2635 CHECK_CALLED(QueryInterface_IServiceProvider
);
2637 SET_EXPECT(GetBindInfo
);
2638 SET_EXPECT(QueryInterface_IInternetProtocol
);
2639 SET_EXPECT(OnStartBinding
);
2640 if(is_urlmon_protocol(test_protocol
))
2641 SET_EXPECT(SetPriority
);
2644 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&unk
);
2645 if(SUCCEEDED(exhres
))
2646 ok(hres
== S_OK
|| hres
== MK_S_ASYNCHRONOUS
, "BindToStorage failed: %08x\n", hres
);
2648 ok(hres
== exhres
|| hres
== MK_S_ASYNCHRONOUS
,
2649 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres
, exhres
);
2651 CHECK_CALLED(GetBindInfo
);
2652 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2653 CHECK_CALLED(OnStartBinding
);
2654 if(is_urlmon_protocol(test_protocol
))
2655 CHECK_CALLED(SetPriority
);
2656 CHECK_CALLED(Start
);
2658 ok(unk
== NULL
, "unk=%p\n", unk
);
2660 IBindCtx_Release(bctx
);
2661 IMoniker_Release(mon
);
2664 static void test_BindToStorage_fail(void)
2666 IMoniker
*mon
= NULL
;
2667 IBindCtx
*bctx
= NULL
;
2671 hres
= CreateURLMoniker(NULL
, ABOUT_BLANK
, &mon
);
2672 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
2676 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
2677 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
2679 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&unk
);
2680 ok(hres
== MK_E_SYNTAX
|| hres
== INET_E_DATA_NOT_AVAILABLE
,
2681 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres
);
2683 IBindCtx_Release(bctx
);
2685 IMoniker_Release(mon
);
2687 test_ReportResult(E_NOTIMPL
);
2688 test_ReportResult(S_FALSE
);
2691 static void test_StdURLMoniker(void)
2693 IMoniker
*mon
, *async_mon
;
2694 LPOLESTR display_name
;
2697 hres
= CoCreateInstance(&IID_IInternet
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
2698 &IID_IMoniker
, (void**)&mon
);
2699 ok(hres
== S_OK
, "Could not create IInternet instance: %08x\n", hres
);
2703 hres
= IMoniker_QueryInterface(mon
, &IID_IAsyncMoniker
, (void**)&async_mon
);
2704 ok(hres
== S_OK
, "Could not get IAsyncMoniker iface: %08x\n", hres
);
2705 ok(mon
== async_mon
, "mon != async_mon\n");
2706 IMoniker_Release(async_mon
);
2708 hres
= IMoniker_GetDisplayName(mon
, NULL
, NULL
, &display_name
);
2709 ok(hres
== E_OUTOFMEMORY
, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres
);
2711 IMoniker_Release(mon
);
2714 static void gecko_installer_workaround(BOOL disable
)
2719 static BOOL has_url
= FALSE
;
2720 static char url
[2048];
2722 if(!disable
&& !has_url
)
2725 res
= RegOpenKey(HKEY_CURRENT_USER
, "Software\\Wine\\MSHTML", &hkey
);
2726 if(res
!= ERROR_SUCCESS
)
2730 DWORD type
, size
= sizeof(url
);
2732 res
= RegQueryValueEx(hkey
, "GeckoUrl", NULL
, &type
, (PVOID
)url
, &size
);
2733 if(res
== ERROR_SUCCESS
&& type
== REG_SZ
)
2736 RegDeleteValue(hkey
, "GeckoUrl");
2738 RegSetValueEx(hkey
, "GeckoUrl", 0, REG_SZ
, (PVOID
)url
, lstrlenA(url
)+1);
2746 gecko_installer_workaround(TRUE
);
2748 complete_event
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2749 complete_event2
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2750 thread_id
= GetCurrentThreadId();
2754 test_CreateAsyncBindCtx();
2755 test_CreateAsyncBindCtxEx();
2757 if(test_RegisterBindStatusCallback()) {
2758 test_BindToStorage_fail();
2760 trace("synchronous http test (COM not initialised)...\n");
2761 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2765 trace("test StdURLMoniker...\n");
2766 test_StdURLMoniker();
2768 trace("synchronous http test...\n");
2769 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2771 trace("synchronous http test (to object)...\n");
2772 test_BindToObject(HTTP_TEST
, FALSE
);
2774 trace("synchronous file test...\n");
2775 test_BindToStorage(FILE_TEST
, FALSE
, TYMED_ISTREAM
);
2777 trace("synchronous file test (to object)...\n");
2778 test_BindToObject(FILE_TEST
, FALSE
);
2780 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
2782 trace("http test...\n");
2783 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2785 trace("http test (to file)...\n");
2786 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_FILE
);
2788 trace("http test (to object)...\n");
2789 test_BindToObject(HTTP_TEST
, FALSE
);
2791 trace("http test (short response)...\n");
2792 http_is_first
= TRUE
;
2793 urls
[HTTP_TEST
] = SHORT_RESPONSE_URL
;
2794 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2796 trace("http test (short response, to object)...\n");
2797 test_BindToObject(HTTP_TEST
, FALSE
);
2799 trace("emulated http test...\n");
2800 test_BindToStorage(HTTP_TEST
, TRUE
, TYMED_ISTREAM
);
2802 trace("emulated http test (to object)...\n");
2803 test_BindToObject(HTTP_TEST
, TRUE
);
2805 trace("emulated http test (to file)...\n");
2806 test_BindToStorage(HTTP_TEST
, TRUE
, TYMED_FILE
);
2808 trace("asynchronous https test...\n");
2809 test_BindToStorage(HTTPS_TEST
, FALSE
, TYMED_ISTREAM
);
2811 trace("emulated https test...\n");
2812 test_BindToStorage(HTTPS_TEST
, TRUE
, TYMED_ISTREAM
);
2814 trace("about test...\n");
2815 test_BindToStorage(ABOUT_TEST
, FALSE
, TYMED_ISTREAM
);
2817 trace("about test (to file)...\n");
2818 test_BindToStorage(ABOUT_TEST
, FALSE
, TYMED_FILE
);
2820 trace("about test (to object)...\n");
2821 test_BindToObject(ABOUT_TEST
, FALSE
);
2823 trace("emulated about test...\n");
2824 test_BindToStorage(ABOUT_TEST
, TRUE
, TYMED_ISTREAM
);
2826 trace("emulated about test (to file)...\n");
2827 test_BindToStorage(ABOUT_TEST
, TRUE
, TYMED_FILE
);
2829 trace("emulated about test (to object)...\n");
2830 test_BindToObject(ABOUT_TEST
, TRUE
);
2832 trace("file test...\n");
2833 test_BindToStorage(FILE_TEST
, FALSE
, TYMED_ISTREAM
);
2835 trace("file test (to file)...\n");
2836 test_BindToStorage(FILE_TEST
, FALSE
, TYMED_FILE
);
2838 trace("file test (to object)...\n");
2839 test_BindToObject(FILE_TEST
, FALSE
);
2841 trace("emulated file test...\n");
2842 test_BindToStorage(FILE_TEST
, TRUE
, TYMED_ISTREAM
);
2844 trace("emulated file test (to file)...\n");
2845 test_BindToStorage(FILE_TEST
, TRUE
, TYMED_FILE
);
2847 trace("emulated file test (to object)...\n");
2848 test_BindToObject(FILE_TEST
, TRUE
);
2850 trace("emulated its test...\n");
2851 test_BindToStorage(ITS_TEST
, TRUE
, TYMED_ISTREAM
);
2853 trace("emulated its test (to file)...\n");
2854 test_BindToStorage(ITS_TEST
, TRUE
, TYMED_FILE
);
2856 trace("emulated mk test...\n");
2857 test_BindToStorage(MK_TEST
, TRUE
, TYMED_ISTREAM
);
2859 trace("test URLDownloadToFile for file protocol...\n");
2860 test_URLDownloadToFile(FILE_TEST
, FALSE
);
2862 trace("test URLDownloadToFile for emulated file protocol...\n");
2863 test_URLDownloadToFile(FILE_TEST
, TRUE
);
2865 trace("test URLDownloadToFile for http protocol...\n");
2866 test_URLDownloadToFile(HTTP_TEST
, FALSE
);
2868 bindf
|= BINDF_NOWRITECACHE
;
2870 trace("ftp test...\n");
2871 test_BindToStorage(FTP_TEST
, FALSE
, TYMED_ISTREAM
);
2873 trace("test failures...\n");
2874 test_BindToStorage_fail();
2877 DeleteFileA(wszIndexHtmlA
);
2878 CloseHandle(complete_event
);
2879 CloseHandle(complete_event2
);
2882 gecko_installer_workaround(FALSE
);