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
35 #include "wine/test.h"
37 #define DEFINE_EXPECT(func) \
38 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
40 #define SET_EXPECT(func) \
41 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
43 #define CHECK_EXPECT2(func) \
45 ok(expect_ ##func, "unexpected call " #func "\n"); \
46 if(0) trace("%s\n", #func); \
47 called_ ## func = TRUE; \
50 #define CHECK_EXPECT(func) \
52 CHECK_EXPECT2(func); \
53 expect_ ## func = FALSE; \
56 #define CHECK_CALLED(func) \
58 ok(called_ ## func, "expected " #func "\n"); \
59 expect_ ## func = called_ ## func = FALSE; \
62 #define CHECK_NOT_CALLED(func) \
64 ok(!called_ ## func, "unexpected " #func "\n"); \
65 expect_ ## func = called_ ## func = FALSE; \
68 #define CLEAR_CALLED(func) \
69 expect_ ## func = called_ ## func = FALSE
71 DEFINE_EXPECT(QueryInterface_IServiceProvider
);
72 DEFINE_EXPECT(QueryInterface_IHttpNegotiate
);
73 DEFINE_EXPECT(QueryInterface_IBindStatusCallback
);
74 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder
);
75 DEFINE_EXPECT(QueryInterface_IInternetBindInfo
);
76 DEFINE_EXPECT(QueryInterface_IAuthenticate
);
77 DEFINE_EXPECT(QueryInterface_IInternetProtocol
);
78 DEFINE_EXPECT(QueryService_IAuthenticate
);
79 DEFINE_EXPECT(QueryService_IInternetProtocol
);
80 DEFINE_EXPECT(QueryService_IInternetBindInfo
);
81 DEFINE_EXPECT(BeginningTransaction
);
82 DEFINE_EXPECT(OnResponse
);
83 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2
);
84 DEFINE_EXPECT(GetRootSecurityId
);
85 DEFINE_EXPECT(GetBindInfo
);
86 DEFINE_EXPECT(OnStartBinding
);
87 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE
);
88 DEFINE_EXPECT(OnProgress_CONNECTING
);
89 DEFINE_EXPECT(OnProgress_SENDINGREQUEST
);
90 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
91 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
92 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA
);
93 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA
);
94 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
95 DEFINE_EXPECT(OnStopBinding
);
96 DEFINE_EXPECT(OnDataAvailable
);
97 DEFINE_EXPECT(OnObjectAvailable
);
98 DEFINE_EXPECT(Obj_OnStartBinding
);
99 DEFINE_EXPECT(Obj_OnStopBinding
);
100 DEFINE_EXPECT(Obj_GetBindInfo
);
101 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
102 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
103 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
104 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
105 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
106 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
107 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
108 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
109 DEFINE_EXPECT(Obj_OnProgress_CONNECTING
);
110 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
111 DEFINE_EXPECT(Start
);
113 DEFINE_EXPECT(LockRequest
);
114 DEFINE_EXPECT(Terminate
);
115 DEFINE_EXPECT(UnlockRequest
);
116 DEFINE_EXPECT(Continue
);
117 DEFINE_EXPECT(CreateInstance
);
119 DEFINE_EXPECT(PutProperty_MIMETYPEPROP
);
120 DEFINE_EXPECT(PutProperty_CLASSIDPROP
);
122 static const WCHAR TEST_URL_1
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
123 static const WCHAR TEST_PART_URL_1
[] = {'/','t','e','s','t','/','\0'};
125 static const WCHAR WINE_ABOUT_URL
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
126 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
127 static const WCHAR SHORT_RESPONSE_URL
[] =
128 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
129 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
130 'p','o','s','t','t','e','s','t','.','p','h','p',0};
131 static const WCHAR ABOUT_BLANK
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
132 static WCHAR INDEX_HTML
[MAX_PATH
];
133 static const WCHAR ITS_URL
[] =
134 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
135 static const WCHAR MK_URL
[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
136 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
138 static const WCHAR wszTextHtml
[] = {'t','e','x','t','/','h','t','m','l',0};
140 static WCHAR BSCBHolder
[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
142 static const WCHAR wszWineHQSite
[] =
143 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
144 static const WCHAR wszWineHQIP
[] =
145 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
146 static const WCHAR wszIndexHtml
[] = {'i','n','d','e','x','.','h','t','m','l',0};
147 static const WCHAR cache_fileW
[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
148 static const WCHAR emptyW
[] = {0};
150 static BOOL stopped_binding
= FALSE
, stopped_obj_binding
= FALSE
, emulate_protocol
= FALSE
,
151 data_available
= FALSE
, http_is_first
= TRUE
, bind_to_object
= FALSE
;
152 static DWORD read
= 0, bindf
= 0, prot_state
= 0, thread_id
, tymed
;
153 static CHAR mime_type
[512];
154 static IInternetProtocolSink
*protocol_sink
= NULL
;
155 static HANDLE complete_event
, complete_event2
;
156 static HRESULT binding_hres
;
158 extern IID IID_IBindStatusCallbackHolder
;
160 static LPCWSTR urls
[] = {
182 static const char *debugstr_w(LPCWSTR str
)
184 static char buf
[1024];
185 WideCharToMultiByte(CP_ACP
, 0, str
, -1, buf
, sizeof(buf
), NULL
, NULL
);
189 static const char *debugstr_guid(REFIID riid
)
193 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
194 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
195 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
196 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
201 static void test_CreateURLMoniker(LPCWSTR url1
, LPCWSTR url2
)
204 IMoniker
*mon1
= NULL
;
205 IMoniker
*mon2
= NULL
;
207 hr
= CreateURLMoniker(NULL
, url1
, &mon1
);
208 ok(SUCCEEDED(hr
), "failed to create moniker: 0x%08x\n", hr
);
210 hr
= CreateURLMoniker(mon1
, url2
, &mon2
);
211 ok(SUCCEEDED(hr
), "failed to create moniker: 0x%08x\n", hr
);
213 if(mon1
) IMoniker_Release(mon1
);
214 if(mon2
) IMoniker_Release(mon2
);
217 static void test_create(void)
219 test_CreateURLMoniker(TEST_URL_1
, TEST_PART_URL_1
);
222 static HRESULT WINAPI
Protocol_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
224 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
230 return E_NOINTERFACE
;
233 static ULONG WINAPI
Protocol_AddRef(IInternetProtocol
*iface
)
238 static ULONG WINAPI
Protocol_Release(IInternetProtocol
*iface
)
243 static DWORD WINAPI
thread_proc(PVOID arg
)
245 PROTOCOLDATA protocoldata
;
249 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
251 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
252 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
253 BINDSTATUS_FINDINGRESOURCE
, wszWineHQSite
);
254 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
255 WaitForSingleObject(complete_event
, INFINITE
);
257 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
259 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
262 SET_EXPECT(Obj_OnProgress_CONNECTING
);
264 SET_EXPECT(OnProgress_CONNECTING
);
265 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
266 BINDSTATUS_CONNECTING
, wszWineHQIP
);
267 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
268 WaitForSingleObject(complete_event
, INFINITE
);
270 CHECK_CALLED(Obj_OnProgress_CONNECTING
);
272 CHECK_CALLED(OnProgress_CONNECTING
);
275 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
277 SET_EXPECT(OnProgress_SENDINGREQUEST
);
278 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
279 BINDSTATUS_SENDINGREQUEST
, NULL
);
280 ok(hres
== S_OK
, "ReportProxgress failed: %08x\n", hres
);
281 WaitForSingleObject(complete_event
, INFINITE
);
283 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
285 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
287 SET_EXPECT(Continue
);
289 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
290 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
291 WaitForSingleObject(complete_event
, INFINITE
);
293 CHECK_CALLED(Continue
);
296 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
297 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
298 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
299 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
300 CHECK_CALLED(CreateInstance
);
301 CHECK_CALLED(PutProperty_MIMETYPEPROP
);
302 CLEAR_CALLED(PutProperty_CLASSIDPROP
);
304 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
305 CHECK_CALLED(OnObjectAvailable
);
306 CHECK_CALLED(Obj_OnStopBinding
);
308 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
309 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
310 CHECK_CALLED(LockRequest
);
311 CHECK_CALLED(OnDataAvailable
);
314 SET_EXPECT(Continue
);
316 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
317 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
318 WaitForSingleObject(complete_event
, INFINITE
);
319 CHECK_CALLED(Continue
);
321 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
322 CHECK_CALLED(OnDataAvailable
);
324 SET_EXPECT(Continue
);
326 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
327 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
328 WaitForSingleObject(complete_event
, INFINITE
);
329 CHECK_CALLED(Continue
);
331 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
332 CHECK_CALLED(OnDataAvailable
);
334 SET_EXPECT(Continue
);
336 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
337 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
338 WaitForSingleObject(complete_event
, INFINITE
);
339 CHECK_CALLED(Continue
);
341 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
342 CHECK_CALLED(OnDataAvailable
);
343 CHECK_CALLED(OnStopBinding
);
347 SetEvent(complete_event2
);
351 static HRESULT WINAPI
Protocol_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
352 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
353 DWORD grfPI
, DWORD dwReserved
)
356 DWORD bindf
, bscf
= BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
;
359 static const STGMEDIUM stgmed_zero
= {0};
360 static const SECURITY_ATTRIBUTES sa_zero
= {0};
366 ok(szUrl
&& !lstrcmpW(szUrl
, urls
[test_protocol
]), "wrong url\n");
367 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
368 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
369 ok(grfPI
== 0, "grfPI=%d, expected 0\n", grfPI
);
370 ok(dwReserved
== 0, "dwReserved=%d, expected 0\n", dwReserved
);
372 if(binding_hres
!= S_OK
) {
373 SET_EXPECT(OnStopBinding
);
374 SET_EXPECT(Terminate
);
375 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, binding_hres
, 0, NULL
);
376 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
377 CHECK_CALLED(OnStopBinding
);
378 CHECK_CALLED(Terminate
);
383 memset(&bindinfo
, 0, sizeof(bindinfo
));
384 bindinfo
.cbSize
= sizeof(bindinfo
);
385 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &bindf
, &bindinfo
);
386 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
388 if(tymed
== TYMED_ISTREAM
389 && (test_protocol
== FILE_TEST
|| test_protocol
== MK_TEST
|| test_protocol
== HTTP_TEST
)) {
390 ok(bindf
== (BINDF_ASYNCHRONOUS
|BINDF_ASYNCSTORAGE
|BINDF_PULLDATA
392 "bindf=%08x\n", bindf
);
394 ok(bindf
== (BINDF_ASYNCHRONOUS
|BINDF_ASYNCSTORAGE
|BINDF_PULLDATA
|
395 BINDF_FROMURLMON
|BINDF_NEEDFILE
),
396 "bindf=%08x\n", bindf
);
399 ok(bindinfo
.cbSize
== sizeof(bindinfo
), "bindinfo.cbSize = %d\n", bindinfo
.cbSize
);
400 ok(!bindinfo
.szExtraInfo
, "bindinfo.szExtraInfo = %p\n", bindinfo
.szExtraInfo
);
401 ok(!memcmp(&bindinfo
.stgmedData
, &stgmed_zero
, sizeof(STGMEDIUM
)), "wrong stgmedData\n");
402 ok(!bindinfo
.grfBindInfoF
, "bindinfo.grfBindInfoF = %d\n", bindinfo
.grfBindInfoF
);
403 ok(!bindinfo
.dwBindVerb
, "bindinfo.dwBindVerb = %d\n", bindinfo
.dwBindVerb
);
404 ok(!bindinfo
.szCustomVerb
, "bindinfo.szCustomVerb = %p\n", bindinfo
.szCustomVerb
);
405 ok(!bindinfo
.cbstgmedData
, "bindinfo.cbstgmedData = %d\n", bindinfo
.cbstgmedData
);
406 ok(bindinfo
.dwOptions
== (bind_to_object
? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo
.dwOptions
);
407 ok(!bindinfo
.dwOptionsFlags
, "bindinfo.dwOptionsFlags = %d\n", bindinfo
.dwOptionsFlags
);
408 ok(!bindinfo
.dwCodePage
, "bindinfo.dwCodePage = %d\n", bindinfo
.dwCodePage
);
409 ok(!memcmp(&bindinfo
.securityAttributes
, &sa_zero
, sizeof(sa_zero
)), "wrong bindinfo.securityAttributes\n");
410 ok(IsEqualGUID(&bindinfo
.iid
, &IID_NULL
), "wrong bindinfo.iid\n");
411 ok(!bindinfo
.pUnk
, "bindinfo.pUnk = %p\n", bindinfo
.pUnk
);
412 ok(!bindinfo
.dwReserved
, "bindinfo.dwReserved = %d\n", bindinfo
.dwReserved
);
414 switch(test_protocol
) {
416 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
417 BINDSTATUS_DIRECTBIND
, NULL
);
419 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
424 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
426 SET_EXPECT(OnProgress_SENDINGREQUEST
);
427 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
428 BINDSTATUS_SENDINGREQUEST
, emptyW
);
430 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
432 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
434 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
439 if(test_protocol
== HTTP_TEST
) {
440 IServiceProvider
*service_provider
;
441 IHttpNegotiate
*http_negotiate
;
442 IHttpNegotiate2
*http_negotiate2
;
443 LPWSTR ua
= (LPWSTR
)0xdeadbeef, accept_mimes
[256];
444 LPWSTR additional_headers
= (LPWSTR
)0xdeadbeef;
446 DWORD fetched
= 256, size
= 100;
448 static const WCHAR wszMimes
[] = {'*','/','*',0};
450 SET_EXPECT(QueryInterface_IInternetBindInfo
);
451 SET_EXPECT(QueryService_IInternetBindInfo
);
452 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_USER_AGENT
,
455 CHECK_CALLED(QueryInterface_IInternetBindInfo
);
456 CHECK_CALLED(QueryService_IInternetBindInfo
);
458 ok(hres
== E_NOINTERFACE
,
459 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres
);
460 ok(fetched
== 256, "fetched = %d, expected 254\n", fetched
);
461 ok(ua
== (LPWSTR
)0xdeadbeef, "ua = %p\n", ua
);
463 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
464 accept_mimes
, 256, &fetched
);
466 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
467 ok(fetched
== 1, "fetched = %d, expected 1\n", fetched
);
468 ok(!lstrcmpW(wszMimes
, accept_mimes
[0]), "unexpected mimes\n");
470 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
471 NULL
, 256, &fetched
);
472 ok(hres
== E_INVALIDARG
,
473 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
475 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
476 accept_mimes
, 256, NULL
);
477 ok(hres
== E_INVALIDARG
,
478 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
480 hres
= IInternetBindInfo_QueryInterface(pOIBindInfo
, &IID_IServiceProvider
,
481 (void**)&service_provider
);
482 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
484 SET_EXPECT(QueryInterface_IHttpNegotiate
);
485 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
486 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
487 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
488 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
490 SET_EXPECT(BeginningTransaction
);
491 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, urls
[test_protocol
],
492 NULL
, 0, &additional_headers
);
493 CHECK_CALLED(BeginningTransaction
);
494 IHttpNegotiate_Release(http_negotiate
);
495 ok(hres
== S_OK
, "BeginningTransction failed: %08x\n", hres
);
496 ok(additional_headers
== NULL
, "additional_headers=%p\n", additional_headers
);
498 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
499 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate2
,
500 &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
501 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
502 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
505 SET_EXPECT(GetRootSecurityId
);
506 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, sec_id
, &size
, 0);
507 CHECK_CALLED(GetRootSecurityId
);
508 IHttpNegotiate2_Release(http_negotiate2
);
509 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres
);
510 ok(size
== 13, "size=%d\n", size
);
512 IServiceProvider_Release(service_provider
);
514 IInternetProtocolSink_AddRef(pOIProtSink
);
515 protocol_sink
= pOIProtSink
;
516 CreateThread(NULL
, 0, thread_proc
, NULL
, 0, NULL
);
521 if(test_protocol
== FILE_TEST
) {
522 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
523 BINDSTATUS_CACHEFILENAMEAVAILABLE
, INDEX_HTML
+7);
525 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
528 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
530 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
531 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
532 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
, wszTextHtml
);
534 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres
);
536 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
538 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
540 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
541 BINDSTATUS_MIMETYPEAVAILABLE
, wszTextHtml
);
543 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
546 if(test_protocol
== ABOUT_TEST
)
547 bscf
|= BSCF_DATAFULLYAVAILABLE
;
548 if(test_protocol
== ITS_TEST
)
549 bscf
= BSCF_FIRSTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
;
553 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
554 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
555 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
556 if(test_protocol
== FILE_TEST
)
557 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
558 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
559 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
560 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
561 SET_EXPECT(CreateInstance
);
562 SET_EXPECT(PutProperty_MIMETYPEPROP
);
563 SET_EXPECT(PutProperty_CLASSIDPROP
);
565 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
566 SET_EXPECT(OnObjectAvailable
);
567 SET_EXPECT(Obj_OnStopBinding
);
569 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
570 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
571 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
572 if(test_protocol
== FILE_TEST
)
573 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
574 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
575 SET_EXPECT(LockRequest
);
576 SET_EXPECT(OnDataAvailable
);
577 SET_EXPECT(OnStopBinding
);
580 hres
= IInternetProtocolSink_ReportData(pOIProtSink
, bscf
, 13, 13);
581 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
585 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
586 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
587 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
588 if(test_protocol
== FILE_TEST
)
589 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
590 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA
);
591 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
592 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
593 CHECK_CALLED(CreateInstance
);
594 CHECK_CALLED(PutProperty_MIMETYPEPROP
);
595 CLEAR_CALLED(PutProperty_CLASSIDPROP
);
597 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
598 CHECK_CALLED(OnObjectAvailable
);
599 CHECK_CALLED(Obj_OnStopBinding
);
601 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
602 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
603 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
604 if(test_protocol
== FILE_TEST
)
605 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
606 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
607 CHECK_CALLED(LockRequest
);
608 CHECK_CALLED(OnDataAvailable
);
609 CHECK_CALLED(OnStopBinding
);
612 if(test_protocol
== ITS_TEST
) {
614 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_BEGINDOWNLOADDATA
, NULL
);
615 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres
);
619 SET_EXPECT(Terminate
);
620 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, S_OK
, 0, NULL
);
621 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
622 CHECK_CALLED(Terminate
);
627 static HRESULT WINAPI
Protocol_Continue(IInternetProtocol
*iface
,
628 PROTOCOLDATA
*pProtocolData
)
633 CHECK_EXPECT(Continue
);
635 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
637 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
643 IServiceProvider
*service_provider
;
644 IHttpNegotiate
*http_negotiate
;
645 static WCHAR header
[] = {'?',0};
647 hres
= IInternetProtocolSink_QueryInterface(protocol_sink
, &IID_IServiceProvider
,
648 (void**)&service_provider
);
649 ok(hres
== S_OK
, "Could not get IServiceProvicder\n");
651 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
652 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
653 ok(hres
== S_OK
, "Could not get IHttpNegotiate\n");
655 SET_EXPECT(OnResponse
);
656 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, header
, NULL
, NULL
);
657 CHECK_CALLED(OnResponse
);
658 IHttpNegotiate_Release(http_negotiate
);
659 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
661 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
662 BINDSTATUS_MIMETYPEAVAILABLE
, wszTextHtml
);
664 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
666 if(tymed
== TYMED_FILE
) {
667 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
668 BINDSTATUS_CACHEFILENAMEAVAILABLE
, cache_fileW
);
670 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
673 bscf
|= BSCF_FIRSTDATANOTIFICATION
;
678 bscf
= BSCF_INTERMEDIATEDATANOTIFICATION
;
682 hres
= IInternetProtocolSink_ReportData(protocol_sink
, bscf
, 100, 400);
683 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
689 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
690 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
691 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
692 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
693 SET_EXPECT(CreateInstance
);
694 SET_EXPECT(PutProperty_MIMETYPEPROP
);
695 SET_EXPECT(PutProperty_CLASSIDPROP
);
697 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
698 SET_EXPECT(OnObjectAvailable
);
699 SET_EXPECT(Obj_OnStopBinding
);
701 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
702 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
703 SET_EXPECT(LockRequest
);
707 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
710 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
711 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
713 if(!bind_to_object
|| prot_state
>= 2)
714 SET_EXPECT(OnDataAvailable
);
716 SET_EXPECT(OnStopBinding
);
721 static HRESULT WINAPI
Protocol_Abort(IInternetProtocol
*iface
, HRESULT hrReason
,
724 ok(0, "unexpected call\n");
728 static HRESULT WINAPI
Protocol_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
730 CHECK_EXPECT(Terminate
);
732 ok(dwOptions
== 0, "dwOptions=%d, expected 0\n", dwOptions
);
735 IInternetProtocolSink_Release(protocol_sink
);
736 protocol_sink
= NULL
;
742 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocol
*iface
)
744 ok(0, "unexpected call\n");
748 static HRESULT WINAPI
Protocol_Resume(IInternetProtocol
*iface
)
750 ok(0, "unexpected call\n");
754 static HRESULT WINAPI
Protocol_Read(IInternetProtocol
*iface
, void *pv
,
755 ULONG cb
, ULONG
*pcbRead
)
757 static const char data
[] = "<HTML></HTML>";
761 if(test_protocol
== HTTP_TEST
) {
764 static BOOL pending
= TRUE
;
786 hres
= IInternetProtocolSink_ReportData(protocol_sink
,
787 BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
, 2000, 2000);
788 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
790 hres
= IInternetProtocolSink_ReportResult(protocol_sink
, S_OK
, 0, NULL
);
791 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
805 ok(pv
!= NULL
, "pv == NULL\n");
806 ok(cb
!= 0, "cb == 0\n");
807 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
809 ok(*pcbRead
== 0, "*pcbRead=%d, expected 0\n", *pcbRead
);
810 read
+= *pcbRead
= sizeof(data
)-1;
813 memcpy(pv
, data
, sizeof(data
));
818 static HRESULT WINAPI
Protocol_Seek(IInternetProtocol
*iface
,
819 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
821 ok(0, "unexpected call\n");
825 static HRESULT WINAPI
Protocol_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
827 CHECK_EXPECT(LockRequest
);
831 static HRESULT WINAPI
Protocol_UnlockRequest(IInternetProtocol
*iface
)
833 CHECK_EXPECT(UnlockRequest
);
837 static const IInternetProtocolVtbl ProtocolVtbl
= {
838 Protocol_QueryInterface
,
849 Protocol_LockRequest
,
850 Protocol_UnlockRequest
853 static IInternetProtocol Protocol
= { &ProtocolVtbl
};
855 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
, REFIID riid
, void **ppv
)
857 if(IsEqualGUID(&IID_IUnknown
, riid
)
858 || IsEqualGUID(&IID_IHttpNegotiate
, riid
)
859 || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
864 ok(0, "unexpected call\n");
865 return E_NOINTERFACE
;
868 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
873 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
878 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
, LPCWSTR szURL
,
879 LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
881 CHECK_EXPECT(BeginningTransaction
);
883 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
885 ok(!lstrcmpW(szURL
, urls
[test_protocol
]), "szURL != urls[test_protocol]\n");
886 ok(!dwReserved
, "dwReserved=%d, expected 0\n", dwReserved
);
887 ok(pszAdditionalHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
888 if(pszAdditionalHeaders
)
889 ok(*pszAdditionalHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
894 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
895 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
897 CHECK_EXPECT(OnResponse
);
899 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
901 ok(dwResponseCode
== 200, "dwResponseCode=%d, expected 200\n", dwResponseCode
);
902 ok(szResponseHeaders
!= NULL
, "szResponseHeaders == NULL\n");
903 ok(szRequestHeaders
== NULL
, "szRequestHeaders != NULL\n");
904 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
905 ok(pszAdditionalRequestHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
906 if(pszAdditionalRequestHeaders
)
907 ok(*pszAdditionalRequestHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
912 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
913 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
915 static const BYTE sec_id
[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
917 CHECK_EXPECT(GetRootSecurityId
);
919 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
921 ok(!dwReserved
, "dwReserved=%ld, expected 0\n", dwReserved
);
922 ok(pbSecurityId
!= NULL
, "pbSecurityId == NULL\n");
923 ok(pcbSecurityId
!= NULL
, "pcbSecurityId == NULL\n");
925 if(pbSecurityId
== (void*)0xdeadbeef)
929 ok(*pcbSecurityId
== 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId
);
930 *pcbSecurityId
= sizeof(sec_id
);
934 memcpy(pbSecurityId
, sec_id
, sizeof(sec_id
));
939 static IHttpNegotiate2Vtbl HttpNegotiateVtbl
= {
940 HttpNegotiate_QueryInterface
,
941 HttpNegotiate_AddRef
,
942 HttpNegotiate_Release
,
943 HttpNegotiate_BeginningTransaction
,
944 HttpNegotiate_OnResponse
,
945 HttpNegotiate_GetRootSecurityId
948 static IHttpNegotiate2 HttpNegotiate
= { &HttpNegotiateVtbl
};
950 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
952 ok(0, "unexpected call\n");
953 return E_NOINTERFACE
;
956 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
961 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
966 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
,
967 REFGUID guidService
, REFIID riid
, void **ppv
)
969 if(IsEqualGUID(&IID_IAuthenticate
, guidService
)) {
970 CHECK_EXPECT(QueryService_IAuthenticate
);
974 if(IsEqualGUID(&IID_IInternetProtocol
, guidService
)) {
975 CHECK_EXPECT2(QueryService_IInternetProtocol
);
979 if(IsEqualGUID(&IID_IInternetBindInfo
, guidService
)) {
980 CHECK_EXPECT(QueryService_IInternetBindInfo
);
984 ok(0, "unexpected service %s\n", debugstr_guid(guidService
));
985 return E_NOINTERFACE
;
988 static IServiceProviderVtbl ServiceProviderVtbl
= {
989 ServiceProvider_QueryInterface
,
990 ServiceProvider_AddRef
,
991 ServiceProvider_Release
,
992 ServiceProvider_QueryService
995 static IServiceProvider ServiceProvider
= { &ServiceProviderVtbl
};
997 static IBindStatusCallback objbsc
;
999 static HRESULT WINAPI
statusclb_QueryInterface(IBindStatusCallback
*iface
, REFIID riid
, void **ppv
)
1001 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1003 if(IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
1004 CHECK_EXPECT2(QueryInterface_IInternetProtocol
);
1005 if(emulate_protocol
) {
1009 return E_NOINTERFACE
;
1012 else if (IsEqualGUID(&IID_IServiceProvider
, riid
))
1014 CHECK_EXPECT2(QueryInterface_IServiceProvider
);
1015 *ppv
= &ServiceProvider
;
1018 else if (IsEqualGUID(&IID_IHttpNegotiate
, riid
))
1020 CHECK_EXPECT(QueryInterface_IHttpNegotiate
);
1021 *ppv
= &HttpNegotiate
;
1024 else if (IsEqualGUID(&IID_IHttpNegotiate2
, riid
))
1026 CHECK_EXPECT(QueryInterface_IHttpNegotiate2
);
1027 *ppv
= &HttpNegotiate
;
1030 else if (IsEqualGUID(&IID_IAuthenticate
, riid
))
1032 CHECK_EXPECT(QueryInterface_IAuthenticate
);
1033 return E_NOINTERFACE
;
1035 else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
))
1037 CHECK_EXPECT2(QueryInterface_IBindStatusCallback
);
1041 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder
, riid
))
1043 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder
);
1044 return E_NOINTERFACE
;
1046 else if(IsEqualGUID(&IID_IInternetBindInfo
, riid
))
1049 CHECK_EXPECT2(QueryInterface_IInternetBindInfo
);
1053 ok(0, "unexpected interface %s\n", debugstr_guid(riid
));
1056 return E_NOINTERFACE
;
1059 static ULONG WINAPI
statusclb_AddRef(IBindStatusCallback
*iface
)
1064 static ULONG WINAPI
statusclb_Release(IBindStatusCallback
*iface
)
1069 static HRESULT WINAPI
statusclb_OnStartBinding(IBindStatusCallback
*iface
, DWORD dwReserved
,
1072 IWinInetHttpInfo
*http_info
;
1076 if(iface
== &objbsc
)
1077 CHECK_EXPECT(Obj_OnStartBinding
);
1079 CHECK_EXPECT(OnStartBinding
);
1081 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1083 ok(pib
!= NULL
, "pib should not be NULL\n");
1084 ok(dwReserved
== 0xff, "dwReserved=%x\n", dwReserved
);
1086 if(pib
== (void*)0xdeadbeef)
1089 hres
= IBinding_QueryInterface(pib
, &IID_IMoniker
, (void**)&mon
);
1090 ok(hres
== E_NOINTERFACE
, "IBinding should not have IMoniker interface\n");
1092 IMoniker_Release(mon
);
1094 hres
= IBinding_QueryInterface(pib
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
1095 ok(hres
== E_NOINTERFACE
, "Could not get IID_IWinInetHttpInfo: %08x\n", hres
);
1100 static HRESULT WINAPI
statusclb_GetPriority(IBindStatusCallback
*iface
, LONG
*pnPriority
)
1102 ok(0, "unexpected call\n");
1106 static HRESULT WINAPI
statusclb_OnLowResource(IBindStatusCallback
*iface
, DWORD reserved
)
1108 ok(0, "unexpected call\n");
1112 static HRESULT WINAPI
statusclb_OnProgress(IBindStatusCallback
*iface
, ULONG ulProgress
,
1113 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
1115 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1117 switch(ulStatusCode
) {
1118 case BINDSTATUS_FINDINGRESOURCE
:
1119 if(iface
== &objbsc
)
1120 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
1122 CHECK_EXPECT(OnProgress_FINDINGRESOURCE
);
1123 if((bindf
& BINDF_ASYNCHRONOUS
) && emulate_protocol
)
1124 SetEvent(complete_event
);
1126 case BINDSTATUS_CONNECTING
:
1127 if(iface
== &objbsc
)
1128 CHECK_EXPECT(Obj_OnProgress_CONNECTING
);
1130 CHECK_EXPECT(OnProgress_CONNECTING
);
1131 if((bindf
& BINDF_ASYNCHRONOUS
) && emulate_protocol
)
1132 SetEvent(complete_event
);
1134 case BINDSTATUS_SENDINGREQUEST
:
1135 if(iface
== &objbsc
)
1136 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
1138 CHECK_EXPECT(OnProgress_SENDINGREQUEST
);
1139 if((bindf
& BINDF_ASYNCHRONOUS
) && emulate_protocol
)
1140 SetEvent(complete_event
);
1142 case BINDSTATUS_MIMETYPEAVAILABLE
:
1143 if(iface
== &objbsc
)
1144 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
1146 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
1148 ok(download_state
== BEFORE_DOWNLOAD
, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1150 WideCharToMultiByte(CP_ACP
, 0, szStatusText
, -1, mime_type
, sizeof(mime_type
)-1, NULL
, NULL
);
1152 case BINDSTATUS_BEGINDOWNLOADDATA
:
1153 if(iface
== &objbsc
)
1154 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
1156 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
1157 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1159 ok(!lstrcmpW(szStatusText
, urls
[test_protocol
]), "wrong szStatusText\n");
1161 ok(download_state
== BEFORE_DOWNLOAD
, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1163 download_state
= DOWNLOADING
;
1165 case BINDSTATUS_DOWNLOADINGDATA
:
1166 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA
);
1167 if(iface
== &objbsc
)
1168 todo_wine
ok(0, "unexpected call\n");
1169 ok(download_state
== DOWNLOADING
, "Download state was %d, expected DOWNLOADING\n",
1172 case BINDSTATUS_ENDDOWNLOADDATA
:
1173 if(iface
== &objbsc
)
1174 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
1176 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA
);
1177 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1179 ok(!lstrcmpW(szStatusText
, urls
[test_protocol
]), "wrong szStatusText\n");
1180 ok(download_state
== DOWNLOADING
, "Download state was %d, expected DOWNLOADING\n",
1182 download_state
= END_DOWNLOAD
;
1184 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
1185 trace("%s\n", debugstr_w(szStatusText
));
1186 if(test_protocol
!= HTTP_TEST
) {
1187 if(iface
== &objbsc
)
1188 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
1190 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
1192 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
1193 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
1196 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1197 if(szStatusText
&& test_protocol
== FILE_TEST
)
1198 ok(!lstrcmpW(INDEX_HTML
+7, szStatusText
), "wrong szStatusText\n");
1200 case BINDSTATUS_CLASSIDAVAILABLE
:
1204 if(iface
!= &objbsc
)
1205 ok(0, "unexpected call\n");
1206 else if(1||emulate_protocol
)
1207 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
1209 todo_wine
CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
1210 hr
= CLSIDFromString((LPOLESTR
)szStatusText
, &clsid
);
1211 ok(hr
== S_OK
, "CLSIDFromString failed with error 0x%08x\n", hr
);
1212 ok(IsEqualCLSID(&clsid
, &CLSID_HTMLDocument
),
1213 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid
));
1216 case BINDSTATUS_BEGINSYNCOPERATION
:
1217 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
1218 if(iface
!= &objbsc
)
1219 ok(0, "unexpected call\n");
1220 ok(szStatusText
== NULL
, "Expected szStatusText to be NULL\n");
1222 case BINDSTATUS_ENDSYNCOPERATION
:
1223 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
1224 if(iface
!= &objbsc
)
1225 ok(0, "unexpected call\n");
1226 ok(szStatusText
== NULL
, "Expected szStatusText to be NULL\n");
1229 ok(0, "unexpexted code %d\n", ulStatusCode
);
1234 static HRESULT WINAPI
statusclb_OnStopBinding(IBindStatusCallback
*iface
, HRESULT hresult
, LPCWSTR szError
)
1236 if(iface
== &objbsc
) {
1237 CHECK_EXPECT(Obj_OnStopBinding
);
1238 stopped_obj_binding
= TRUE
;
1240 CHECK_EXPECT(OnStopBinding
);
1241 stopped_binding
= TRUE
;
1244 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1246 /* ignore DNS failure */
1247 if (hresult
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
1250 ok(hresult
== binding_hres
, "binding failed: %08x, expected %08x\n", hresult
, binding_hres
);
1251 ok(szError
== NULL
, "szError should be NULL\n");
1253 if(test_protocol
== HTTP_TEST
&& emulate_protocol
) {
1254 SetEvent(complete_event
);
1255 if(iface
!= &objbsc
)
1256 WaitForSingleObject(complete_event2
, INFINITE
);
1262 static HRESULT WINAPI
statusclb_GetBindInfo(IBindStatusCallback
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
1266 if(iface
== &objbsc
)
1267 CHECK_EXPECT(Obj_GetBindInfo
);
1269 CHECK_EXPECT(GetBindInfo
);
1271 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1274 cbSize
= pbindinfo
->cbSize
;
1275 memset(pbindinfo
, 0, cbSize
);
1276 pbindinfo
->cbSize
= cbSize
;
1281 static HRESULT WINAPI
statusclb_OnDataAvailable(IBindStatusCallback
*iface
, DWORD grfBSCF
,
1282 DWORD dwSize
, FORMATETC
* pformatetc
, STGMEDIUM
* pstgmed
)
1289 if(iface
== &objbsc
)
1290 ok(0, "unexpected call\n");
1292 CHECK_EXPECT2(OnDataAvailable
);
1294 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1296 ok(download_state
== DOWNLOADING
|| download_state
== END_DOWNLOAD
,
1297 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1299 data_available
= TRUE
;
1301 ok(pformatetc
!= NULL
, "pformatetx == NULL\n");
1305 ok(GetClipboardFormatName(pformatetc
->cfFormat
, clipfmt
, sizeof(clipfmt
)-1),
1306 "GetClipboardFormatName failed, error %d\n", GetLastError());
1307 ok(!lstrcmp(clipfmt
, mime_type
), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1308 pformatetc
->cfFormat
, clipfmt
, mime_type
);
1310 ok(pformatetc
->cfFormat
== 0, "clipformat=%x\n", pformatetc
->cfFormat
);
1312 ok(pformatetc
->ptd
== NULL
, "ptd = %p\n", pformatetc
->ptd
);
1313 ok(pformatetc
->dwAspect
== 1, "dwAspect=%u\n", pformatetc
->dwAspect
);
1314 ok(pformatetc
->lindex
== -1, "lindex=%d\n", pformatetc
->lindex
);
1315 ok(pformatetc
->tymed
== tymed
, "tymed=%u, expected %u\n", pformatetc
->tymed
, tymed
);
1318 ok(pstgmed
!= NULL
, "stgmeg == NULL\n");
1319 ok(pstgmed
->tymed
== tymed
, "tymed=%u, expected %u\n", pstgmed
->tymed
, tymed
);
1320 ok(pstgmed
->pUnkForRelease
!= NULL
, "pUnkForRelease == NULL\n");
1322 switch(pstgmed
->tymed
) {
1324 if(grfBSCF
& BSCF_FIRSTDATANOTIFICATION
) {
1325 hres
= IStream_Write(U(*pstgmed
).pstm
, buf
, 10, NULL
);
1326 ok(hres
== STG_E_ACCESSDENIED
,
1327 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres
);
1329 hres
= IStream_Commit(U(*pstgmed
).pstm
, 0);
1330 ok(hres
== E_NOTIMPL
, "Commit failed: %08x, expected E_NOTIMPL\n", hres
);
1332 hres
= IStream_Revert(U(*pstgmed
).pstm
);
1333 ok(hres
== E_NOTIMPL
, "Revert failed: %08x, expected E_NOTIMPL\n", hres
);
1336 ok(U(*pstgmed
).pstm
!= NULL
, "U(*pstgmed).pstm == NULL\n");
1337 do hres
= IStream_Read(U(*pstgmed
).pstm
, buf
, 512, &readed
);
1338 while(hres
== S_OK
);
1339 ok(hres
== S_FALSE
|| hres
== E_PENDING
, "IStream_Read returned %08x\n", hres
);
1343 if(test_protocol
== FILE_TEST
)
1344 ok(!lstrcmpW(pstgmed
->u
.lpszFileName
, INDEX_HTML
+7),
1345 "unexpected file name %s\n", debugstr_w(pstgmed
->u
.lpszFileName
));
1346 else if(emulate_protocol
)
1347 ok(!lstrcmpW(pstgmed
->u
.lpszFileName
, cache_fileW
),
1348 "unexpected file name %s\n", debugstr_w(pstgmed
->u
.lpszFileName
));
1350 ok(pstgmed
->u
.lpszFileName
!= NULL
, "lpszFileName == NULL\n");
1353 if(test_protocol
== HTTP_TEST
&& emulate_protocol
&& prot_state
< 4 && (!bind_to_object
|| prot_state
> 1))
1354 SetEvent(complete_event
);
1359 static HRESULT WINAPI
statusclb_OnObjectAvailable(IBindStatusCallback
*iface
, REFIID riid
, IUnknown
*punk
)
1361 CHECK_EXPECT(OnObjectAvailable
);
1363 if(iface
!= &objbsc
)
1364 ok(0, "unexpected call\n");
1366 ok(IsEqualGUID(&IID_IUnknown
, riid
), "riid = %s\n", debugstr_guid(riid
));
1367 ok(punk
!= NULL
, "punk == NULL\n");
1372 static const IBindStatusCallbackVtbl BindStatusCallbackVtbl
= {
1373 statusclb_QueryInterface
,
1376 statusclb_OnStartBinding
,
1377 statusclb_GetPriority
,
1378 statusclb_OnLowResource
,
1379 statusclb_OnProgress
,
1380 statusclb_OnStopBinding
,
1381 statusclb_GetBindInfo
,
1382 statusclb_OnDataAvailable
,
1383 statusclb_OnObjectAvailable
1386 static IBindStatusCallback bsc
= { &BindStatusCallbackVtbl
};
1387 static IBindStatusCallback objbsc
= { &BindStatusCallbackVtbl
};
1389 static HRESULT WINAPI
MonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
1392 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1393 return E_NOINTERFACE
;
1396 static ULONG WINAPI
MonikerProp_AddRef(IMonikerProp
*iface
)
1401 static ULONG WINAPI
MonikerProp_Release(IMonikerProp
*iface
)
1406 static HRESULT WINAPI
MonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
1410 CHECK_EXPECT(PutProperty_MIMETYPEPROP
);
1411 ok(!lstrcmpW(val
, wszTextHtml
), "val = %s\n", debugstr_w(val
));
1414 CHECK_EXPECT(PutProperty_CLASSIDPROP
);
1423 static const IMonikerPropVtbl MonikerPropVtbl
= {
1424 MonikerProp_QueryInterface
,
1426 MonikerProp_Release
,
1427 MonikerProp_PutProperty
1430 static IMonikerProp MonikerProp
= { &MonikerPropVtbl
};
1432 static HRESULT WINAPI
PersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
1436 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IPersistMoniker
, riid
))
1438 else if(IsEqualGUID(&IID_IMonikerProp
, riid
))
1439 *ppv
= &MonikerProp
;
1444 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1445 return E_NOINTERFACE
;
1448 static ULONG WINAPI
PersistMoniker_AddRef(IPersistMoniker
*iface
)
1453 static ULONG WINAPI
PersistMoniker_Release(IPersistMoniker
*iface
)
1458 static HRESULT WINAPI
PersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
1460 ok(0, "unexpected call\n");
1464 static HRESULT WINAPI
PersistMoniker_IsDirty(IPersistMoniker
*iface
)
1466 ok(0, "unexpected call\n");
1470 static HRESULT WINAPI
PersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
1471 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
1476 static WCHAR cbinding_contextW
[] =
1477 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1480 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1482 if(test_protocol
== HTTP_TEST
)
1483 ok(!fFullyAvailable
, "fFulyAvailable = %x\n", fFullyAvailable
);
1485 ok(fFullyAvailable
, "fFulyAvailable = %x\n", fFullyAvailable
);
1486 ok(pimkName
!= NULL
, "pimkName == NULL\n");
1487 ok(pibc
!= NULL
, "pibc == NULL\n");
1488 ok(grfMode
== 0x12, "grfMode = %x\n", grfMode
);
1490 hres
= IBindCtx_GetObjectParam(pibc
, cbinding_contextW
, &unk
);
1491 ok(hres
== S_OK
, "GetObjectParam(CBinding Context) failed: %08x\n", hres
);
1492 if(SUCCEEDED(hres
)) {
1495 hres
= IUnknown_QueryInterface(unk
, &IID_IBinding
, (void**)&binding
);
1496 ok(hres
== S_OK
, "Could not get IBinding: %08x\n", hres
);
1498 IBinding_Release(binding
);
1499 IUnknown_Release(unk
);
1502 SET_EXPECT(QueryInterface_IServiceProvider
);
1503 hres
= RegisterBindStatusCallback(pibc
, &bsc
, NULL
, 0);
1504 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
1505 CHECK_CALLED(QueryInterface_IServiceProvider
);
1507 SET_EXPECT(GetBindInfo
);
1508 SET_EXPECT(OnStartBinding
);
1509 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
1510 if(test_protocol
== FILE_TEST
)
1511 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
1512 if(test_protocol
!= HTTP_TEST
)
1513 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
1514 SET_EXPECT(LockRequest
);
1515 SET_EXPECT(OnDataAvailable
);
1516 if(test_protocol
!= HTTP_TEST
)
1517 SET_EXPECT(OnStopBinding
);
1519 hres
= IMoniker_BindToStorage(pimkName
, pibc
, NULL
, &IID_IStream
, (void**)&unk
);
1520 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
1522 CHECK_CALLED(GetBindInfo
);
1523 CHECK_CALLED(OnStartBinding
);
1524 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
1525 if(test_protocol
== FILE_TEST
)
1526 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
1527 if(test_protocol
!= HTTP_TEST
)
1528 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
1529 CHECK_CALLED(LockRequest
);
1530 CHECK_CALLED(OnDataAvailable
);
1531 if(test_protocol
!= HTTP_TEST
)
1532 CHECK_CALLED(OnStopBinding
);
1535 IUnknown_Release(unk
);
1540 static HRESULT WINAPI
PersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pbc
, BOOL fRemember
)
1542 ok(0, "unexpected call\n");
1546 static HRESULT WINAPI
PersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
1548 ok(0, "unexpected call\n");
1552 static HRESULT WINAPI
PersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**pimkName
)
1554 ok(0, "unexpected call\n");
1558 static const IPersistMonikerVtbl PersistMonikerVtbl
= {
1559 PersistMoniker_QueryInterface
,
1560 PersistMoniker_AddRef
,
1561 PersistMoniker_Release
,
1562 PersistMoniker_GetClassID
,
1563 PersistMoniker_IsDirty
,
1564 PersistMoniker_Load
,
1565 PersistMoniker_Save
,
1566 PersistMoniker_SaveCompleted
,
1567 PersistMoniker_GetCurMoniker
1570 static IPersistMoniker PersistMoniker
= { &PersistMonikerVtbl
};
1572 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1576 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
1581 if(IsEqualGUID(&IID_IMarshal
, riid
))
1582 return E_NOINTERFACE
;
1583 if(IsEqualGUID(&CLSID_IdentityUnmarshal
, riid
))
1584 return E_NOINTERFACE
;
1586 ok(0, "unexpected riid %s\n", debugstr_guid(riid
));
1590 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1595 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1600 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
1602 CHECK_EXPECT(CreateInstance
);
1603 ok(!outer
, "outer = %p\n", outer
);
1604 ok(IsEqualGUID(&IID_IUnknown
, riid
), "unexpected riid %s\n", debugstr_guid(riid
));
1605 *ppv
= &PersistMoniker
;
1609 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1611 ok(0, "unexpected call\n");
1615 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1616 ClassFactory_QueryInterface
,
1617 ClassFactory_AddRef
,
1618 ClassFactory_Release
,
1619 ClassFactory_CreateInstance
,
1620 ClassFactory_LockServer
1623 static IClassFactory mime_cf
= { &ClassFactoryVtbl
};
1625 static void test_CreateAsyncBindCtx(void)
1627 IBindCtx
*bctx
= (IBindCtx
*)0x0ff00ff0;
1633 hres
= CreateAsyncBindCtx(0, NULL
, NULL
, &bctx
);
1634 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres
);
1635 ok(bctx
== (IBindCtx
*)0x0ff00ff0, "bctx should not be changed\n");
1637 hres
= CreateAsyncBindCtx(0, NULL
, NULL
, NULL
);
1638 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres
);
1640 SET_EXPECT(QueryInterface_IServiceProvider
);
1641 hres
= CreateAsyncBindCtx(0, &bsc
, NULL
, &bctx
);
1642 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n", hres
);
1643 CHECK_CALLED(QueryInterface_IServiceProvider
);
1645 bindopts
.cbStruct
= sizeof(bindopts
);
1646 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
1647 ok(SUCCEEDED(hres
), "IBindCtx_GetBindOptions failed: %08x\n", hres
);
1648 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
1649 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
1650 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
1651 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1653 ok(bindopts
.dwTickCountDeadline
== 0,
1654 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
1656 hres
= IBindCtx_QueryInterface(bctx
, &IID_IAsyncBindCtx
, (void**)&unk
);
1657 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres
);
1659 IUnknown_Release(unk
);
1661 ref
= IBindCtx_Release(bctx
);
1662 ok(ref
== 0, "bctx should be destroyed here\n");
1665 static void test_CreateAsyncBindCtxEx(void)
1667 IBindCtx
*bctx
= NULL
, *bctx2
= NULL
, *bctx_arg
= NULL
;
1672 static WCHAR testW
[] = {'t','e','s','t',0};
1674 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, NULL
, 0);
1675 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres
);
1677 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
1678 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1680 if(SUCCEEDED(hres
)) {
1681 bindopts
.cbStruct
= sizeof(bindopts
);
1682 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
1683 ok(SUCCEEDED(hres
), "IBindCtx_GetBindOptions failed: %08x\n", hres
);
1684 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
1685 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
1686 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
1687 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1689 ok(bindopts
.dwTickCountDeadline
== 0,
1690 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
1692 IBindCtx_Release(bctx
);
1695 CreateBindCtx(0, &bctx_arg
);
1696 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
1697 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1699 if(SUCCEEDED(hres
)) {
1700 bindopts
.cbStruct
= sizeof(bindopts
);
1701 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
1702 ok(SUCCEEDED(hres
), "IBindCtx_GetBindOptions failed: %08x\n", hres
);
1703 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
1704 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
1705 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
1706 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1708 ok(bindopts
.dwTickCountDeadline
== 0,
1709 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
1711 IBindCtx_Release(bctx
);
1714 IBindCtx_Release(bctx_arg
);
1716 SET_EXPECT(QueryInterface_IServiceProvider
);
1717 hres
= CreateAsyncBindCtxEx(NULL
, 0, &bsc
, NULL
, &bctx
, 0);
1718 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1719 CHECK_CALLED(QueryInterface_IServiceProvider
);
1721 hres
= IBindCtx_QueryInterface(bctx
, &IID_IAsyncBindCtx
, (void**)&unk
);
1722 ok(hres
== S_OK
, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres
);
1724 IUnknown_Release(unk
);
1726 IBindCtx_Release(bctx
);
1728 hres
= CreateBindCtx(0, &bctx2
);
1729 ok(hres
== S_OK
, "CreateBindCtx failed: %08x\n", hres
);
1731 hres
= CreateAsyncBindCtxEx(bctx2
, 0, NULL
, NULL
, &bctx
, 0);
1732 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
1734 hres
= IBindCtx_RegisterObjectParam(bctx2
, testW
, (IUnknown
*)&Protocol
);
1735 ok(hres
== S_OK
, "RegisterObjectParam failed: %08x\n", hres
);
1737 hres
= IBindCtx_GetObjectParam(bctx
, testW
, &unk
);
1738 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
1739 ok(unk
== (IUnknown
*)&Protocol
, "unexpected unk %p\n", unk
);
1741 IBindCtx_Release(bctx
);
1742 IBindCtx_Release(bctx2
);
1745 static void test_bscholder(IBindStatusCallback
*holder
)
1747 IServiceProvider
*serv_prov
;
1748 IHttpNegotiate
*http_negotiate
, *http_negotiate_serv
;
1749 IHttpNegotiate2
*http_negotiate2
, *http_negotiate2_serv
;
1750 IAuthenticate
*authenticate
, *authenticate_serv
;
1751 IInternetProtocol
*protocol
;
1752 BINDINFO bindinfo
= {sizeof(bindinfo
)};
1757 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IServiceProvider
, (void**)&serv_prov
);
1758 ok(hres
== S_OK
, "Could not get IServiceProvider interface: %08x\n", hres
);
1761 SET_EXPECT(GetBindInfo
);
1762 hres
= IBindStatusCallback_GetBindInfo(holder
, &dw
, &bindinfo
);
1763 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
1764 CHECK_CALLED(GetBindInfo
);
1766 SET_EXPECT(OnStartBinding
);
1767 hres
= IBindStatusCallback_OnStartBinding(holder
, 0, (void*)0xdeadbeef);
1768 ok(hres
== S_OK
, "OnStartBinding failed: %08x\n", hres
);
1769 CHECK_CALLED(OnStartBinding
);
1771 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IHttpNegotiate
, (void**)&http_negotiate
);
1772 ok(hres
== S_OK
, "Could not get IHttpNegotiate interface: %08x\n", hres
);
1774 wstr
= (void*)0xdeadbeef;
1775 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, urls
[test_protocol
], (void*)0xdeadbeef, 0xff, &wstr
);
1776 ok(hres
== S_OK
, "BeginningTransaction failed: %08x\n", hres
);
1777 ok(wstr
== NULL
, "wstr = %p\n", wstr
);
1779 SET_EXPECT(QueryInterface_IHttpNegotiate
);
1780 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate
, &IID_IHttpNegotiate
,
1781 (void**)&http_negotiate_serv
);
1782 ok(hres
== S_OK
, "Could not get IHttpNegotiate service: %08x\n", hres
);
1783 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
1785 ok(http_negotiate
== http_negotiate_serv
, "http_negotiate != http_negotiate_serv\n");
1787 wstr
= (void*)0xdeadbeef;
1788 SET_EXPECT(BeginningTransaction
);
1789 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate_serv
, urls
[test_protocol
], emptyW
, 0, &wstr
);
1790 CHECK_CALLED(BeginningTransaction
);
1791 ok(hres
== S_OK
, "BeginningTransaction failed: %08x\n", hres
);
1792 ok(wstr
== NULL
, "wstr = %p\n", wstr
);
1794 IHttpNegotiate_Release(http_negotiate_serv
);
1796 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate
, &IID_IHttpNegotiate
,
1797 (void**)&http_negotiate_serv
);
1798 ok(hres
== S_OK
, "Could not get IHttpNegotiate service: %08x\n", hres
);
1799 ok(http_negotiate
== http_negotiate_serv
, "http_negotiate != http_negotiate_serv\n");
1800 IHttpNegotiate_Release(http_negotiate_serv
);
1802 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
1803 ok(hres
== S_OK
, "Could not get IHttpNegotiate2 interface: %08x\n", hres
);
1805 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1806 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x\n", hres
);
1808 IHttpNegotiate_Release(http_negotiate2
);
1810 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
1811 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate2
, &IID_IHttpNegotiate2
,
1812 (void**)&http_negotiate2_serv
);
1813 ok(hres
== S_OK
, "Could not get IHttpNegotiate2 service: %08x\n", hres
);
1814 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
1815 ok(http_negotiate2
== http_negotiate2_serv
, "http_negotiate != http_negotiate_serv\n");
1817 SET_EXPECT(GetRootSecurityId
);
1818 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
1819 ok(hres
== E_NOTIMPL
, "GetRootSecurityId failed: %08x\n", hres
);
1820 CHECK_CALLED(GetRootSecurityId
);
1822 IHttpNegotiate_Release(http_negotiate2_serv
);
1824 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
1825 hres
= IBindStatusCallback_OnProgress(holder
, 0, 0, BINDSTATUS_FINDINGRESOURCE
, NULL
);
1826 ok(hres
== S_OK
, "OnProgress failed: %08x\n", hres
);
1827 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
1829 SET_EXPECT(OnResponse
);
1830 wstr
= (void*)0xdeadbeef;
1831 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, emptyW
, NULL
, NULL
);
1832 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
1833 CHECK_CALLED(OnResponse
);
1835 IHttpNegotiate_Release(http_negotiate
);
1837 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IAuthenticate
, (void**)&authenticate
);
1838 ok(hres
== S_OK
, "Could not get IAuthenticate interface: %08x\n", hres
);
1840 SET_EXPECT(QueryInterface_IAuthenticate
);
1841 SET_EXPECT(QueryService_IAuthenticate
);
1842 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IAuthenticate
, &IID_IAuthenticate
,
1843 (void**)&authenticate_serv
);
1844 ok(hres
== S_OK
, "Could not get IAuthenticate service: %08x\n", hres
);
1845 CHECK_CALLED(QueryInterface_IAuthenticate
);
1846 CHECK_CALLED(QueryService_IAuthenticate
);
1847 ok(authenticate
== authenticate_serv
, "authenticate != authenticate_serv\n");
1848 IAuthenticate_Release(authenticate_serv
);
1850 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IAuthenticate
, &IID_IAuthenticate
,
1851 (void**)&authenticate_serv
);
1852 ok(hres
== S_OK
, "Could not get IAuthenticate service: %08x\n", hres
);
1853 ok(authenticate
== authenticate_serv
, "authenticate != authenticate_serv\n");
1855 IAuthenticate_Release(authenticate
);
1856 IAuthenticate_Release(authenticate_serv
);
1858 SET_EXPECT(OnStopBinding
);
1859 hres
= IBindStatusCallback_OnStopBinding(holder
, S_OK
, NULL
);
1860 ok(hres
== S_OK
, "OnStopBinding failed: %08x\n", hres
);
1861 CHECK_CALLED(OnStopBinding
);
1863 SET_EXPECT(QueryInterface_IInternetProtocol
);
1864 SET_EXPECT(QueryService_IInternetProtocol
);
1865 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IInternetProtocol
, &IID_IInternetProtocol
,
1867 ok(hres
== E_NOINTERFACE
, "QueryService(IInternetProtocol) failed: %08x\n", hres
);
1868 CHECK_CALLED(QueryInterface_IInternetProtocol
);
1869 CHECK_CALLED(QueryService_IInternetProtocol
);
1871 IServiceProvider_Release(serv_prov
);
1874 static void test_RegisterBindStatusCallback(void)
1876 IBindStatusCallback
*prevbsc
, *clb
;
1881 hres
= CreateBindCtx(0, &bindctx
);
1882 ok(hres
== S_OK
, "BindCtx failed: %08x\n", hres
);
1884 SET_EXPECT(QueryInterface_IServiceProvider
);
1886 hres
= IBindCtx_RegisterObjectParam(bindctx
, BSCBHolder
, (IUnknown
*)&bsc
);
1887 ok(hres
== S_OK
, "RegisterObjectParam failed: %08x\n", hres
);
1889 SET_EXPECT(QueryInterface_IBindStatusCallback
);
1890 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder
);
1891 prevbsc
= (void*)0xdeadbeef;
1892 hres
= RegisterBindStatusCallback(bindctx
, &bsc
, &prevbsc
, 0);
1893 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
1894 ok(prevbsc
== &bsc
, "prevbsc=%p\n", prevbsc
);
1895 CHECK_CALLED(QueryInterface_IBindStatusCallback
);
1896 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder
);
1898 CHECK_CALLED(QueryInterface_IServiceProvider
);
1900 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
1901 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
1903 hres
= IUnknown_QueryInterface(unk
, &IID_IBindStatusCallback
, (void**)&clb
);
1904 IUnknown_Release(unk
);
1905 ok(hres
== S_OK
, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres
);
1906 ok(clb
!= &bsc
, "bsc == clb\n");
1908 test_bscholder(clb
);
1910 IBindStatusCallback_Release(clb
);
1912 hres
= RevokeBindStatusCallback(bindctx
, &bsc
);
1913 ok(hres
== S_OK
, "RevokeBindStatusCallback failed: %08x\n", hres
);
1915 unk
= (void*)0xdeadbeef;
1916 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
1917 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x\n", hres
);
1918 ok(unk
== NULL
, "unk != NULL\n");
1921 IUnknown_Release(unk
);
1923 hres
= RevokeBindStatusCallback(bindctx
, (void*)0xdeadbeef);
1924 ok(hres
== S_OK
, "RevokeBindStatusCallback failed: %08x\n", hres
);
1926 hres
= RevokeBindStatusCallback(NULL
, (void*)0xdeadbeef);
1927 ok(hres
== E_INVALIDARG
, "RevokeBindStatusCallback failed: %08x\n", hres
);
1929 hres
= RevokeBindStatusCallback(bindctx
, NULL
);
1930 ok(hres
== E_INVALIDARG
, "RevokeBindStatusCallback failed: %08x\n", hres
);
1932 IBindCtx_Release(bindctx
);
1935 static void init_bind_test(int protocol
, BOOL emul
, BOOL bto
, DWORD t
)
1937 test_protocol
= protocol
;
1938 emulate_protocol
= emul
;
1939 download_state
= BEFORE_DOWNLOAD
;
1940 stopped_binding
= FALSE
;
1941 stopped_obj_binding
= FALSE
;
1942 data_available
= FALSE
;
1944 binding_hres
= S_OK
;
1945 bind_to_object
= bto
;
1949 static void test_BindToStorage(int protocol
, BOOL emul
, DWORD t
)
1953 LPOLESTR display_name
;
1956 IBindStatusCallback
*previousclb
;
1957 IUnknown
*unk
= (IUnknown
*)0x00ff00ff;
1960 init_bind_test(protocol
, emul
, FALSE
, t
);
1962 SET_EXPECT(QueryInterface_IServiceProvider
);
1963 hres
= CreateAsyncBindCtx(0, &bsc
, NULL
, &bctx
);
1964 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
1965 CHECK_CALLED(QueryInterface_IServiceProvider
);
1969 SET_EXPECT(QueryInterface_IServiceProvider
);
1970 hres
= RegisterBindStatusCallback(bctx
, &bsc
, &previousclb
, 0);
1971 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
1972 ok(previousclb
== &bsc
, "previousclb(%p) != sclb(%p)\n", previousclb
, &bsc
);
1973 CHECK_CALLED(QueryInterface_IServiceProvider
);
1975 IBindStatusCallback_Release(previousclb
);
1977 hres
= CreateURLMoniker(NULL
, urls
[test_protocol
], &mon
);
1978 ok(SUCCEEDED(hres
), "failed to create moniker: %08x\n", hres
);
1980 IBindCtx_Release(bctx
);
1984 if(test_protocol
== FILE_TEST
&& INDEX_HTML
[7] == '/')
1985 memmove(INDEX_HTML
+7, INDEX_HTML
+8, lstrlenW(INDEX_HTML
+7)*sizeof(WCHAR
));
1987 hres
= IMoniker_QueryInterface(mon
, &IID_IBinding
, (void**)&bind
);
1988 ok(hres
== E_NOINTERFACE
, "IMoniker should not have IBinding interface\n");
1990 IBinding_Release(bind
);
1992 hres
= IMoniker_GetDisplayName(mon
, bctx
, NULL
, &display_name
);
1993 ok(hres
== S_OK
, "GetDisplayName failed %08x\n", hres
);
1994 ok(!lstrcmpW(display_name
, urls
[test_protocol
]),
1995 "GetDisplayName got wrong name %s\n", debugstr_w(display_name
));
1996 CoTaskMemFree(display_name
);
1998 if(tymed
== TYMED_FILE
&& (test_protocol
== ABOUT_TEST
|| test_protocol
== ITS_TEST
))
1999 binding_hres
= INET_E_DATA_NOT_AVAILABLE
;
2001 SET_EXPECT(GetBindInfo
);
2002 SET_EXPECT(QueryInterface_IInternetProtocol
);
2003 if(!emulate_protocol
)
2004 SET_EXPECT(QueryService_IInternetProtocol
);
2005 SET_EXPECT(OnStartBinding
);
2006 if(emulate_protocol
) {
2008 if(test_protocol
== HTTP_TEST
)
2009 SET_EXPECT(Terminate
);
2010 if(tymed
!= TYMED_FILE
|| (test_protocol
!= ABOUT_TEST
&& test_protocol
!= ITS_TEST
))
2011 SET_EXPECT(UnlockRequest
);
2013 if(test_protocol
== HTTP_TEST
) {
2014 SET_EXPECT(QueryInterface_IInternetBindInfo
);
2015 SET_EXPECT(QueryService_IInternetBindInfo
);
2016 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2017 SET_EXPECT(BeginningTransaction
);
2018 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
2019 SET_EXPECT(GetRootSecurityId
);
2020 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
2021 SET_EXPECT(OnProgress_CONNECTING
);
2023 if(test_protocol
== HTTP_TEST
|| test_protocol
== FILE_TEST
)
2024 SET_EXPECT(OnProgress_SENDINGREQUEST
);
2025 if(test_protocol
== HTTP_TEST
)
2026 SET_EXPECT(OnResponse
);
2027 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
2028 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
2029 if(test_protocol
== FILE_TEST
)
2030 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
2031 if(test_protocol
== HTTP_TEST
)
2032 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
2033 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
2034 if(tymed
!= TYMED_FILE
|| test_protocol
!= ABOUT_TEST
)
2035 SET_EXPECT(OnDataAvailable
);
2036 SET_EXPECT(OnStopBinding
);
2039 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, tymed
== TYMED_ISTREAM
? &IID_IStream
: &IID_IUnknown
, (void**)&unk
);
2040 if (test_protocol
== HTTP_TEST
&& hres
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
2042 skip("Network unreachable, skipping tests\n");
2046 if(((bindf
& BINDF_ASYNCHRONOUS
) && !data_available
)
2047 || (tymed
== TYMED_FILE
&& test_protocol
== FILE_TEST
)) {
2048 ok(hres
== MK_S_ASYNCHRONOUS
, "IMoniker_BindToStorage failed: %08x\n", hres
);
2049 ok(unk
== NULL
, "istr should be NULL\n");
2050 }else if(tymed
== TYMED_FILE
&& test_protocol
== ABOUT_TEST
) {
2051 ok(hres
== INET_E_DATA_NOT_AVAILABLE
,
2052 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres
);
2053 ok(unk
== NULL
, "istr should be NULL\n");
2055 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
2056 ok(unk
!= NULL
, "unk == NULL\n");
2059 IUnknown_Release(unk
);
2064 while((bindf
& BINDF_ASYNCHRONOUS
) &&
2065 !stopped_binding
&& GetMessage(&msg
,NULL
,0,0)) {
2066 TranslateMessage(&msg
);
2067 DispatchMessage(&msg
);
2070 CHECK_CALLED(GetBindInfo
);
2071 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2072 if(!emulate_protocol
)
2073 CHECK_CALLED(QueryService_IInternetProtocol
);
2074 CHECK_CALLED(OnStartBinding
);
2075 if(emulate_protocol
) {
2076 CHECK_CALLED(Start
);
2077 if(test_protocol
== HTTP_TEST
) {
2078 if(tymed
== TYMED_FILE
)
2080 CHECK_CALLED(Terminate
);
2082 if(tymed
!= TYMED_FILE
|| (test_protocol
!= ABOUT_TEST
&& test_protocol
!= ITS_TEST
))
2083 CHECK_CALLED(UnlockRequest
);
2085 if(test_protocol
== HTTP_TEST
) {
2086 CLEAR_CALLED(QueryInterface_IInternetBindInfo
);
2087 CLEAR_CALLED(QueryService_IInternetBindInfo
);
2088 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
2089 CHECK_CALLED(BeginningTransaction
);
2090 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
2091 * called on WinXP but not on Win98 */
2092 CLEAR_CALLED(QueryInterface_IHttpNegotiate2
);
2093 CLEAR_CALLED(GetRootSecurityId
);
2095 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
2096 CHECK_CALLED(OnProgress_CONNECTING
);
2098 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE
);
2099 CHECK_NOT_CALLED(OnProgress_CONNECTING
);
2102 if(test_protocol
== HTTP_TEST
|| test_protocol
== FILE_TEST
)
2103 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
2104 if(test_protocol
== HTTP_TEST
)
2105 CHECK_CALLED(OnResponse
);
2106 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
2107 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
2108 if(test_protocol
== FILE_TEST
)
2109 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
2110 if(test_protocol
== HTTP_TEST
)
2111 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
2112 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
2113 if(tymed
!= TYMED_FILE
|| test_protocol
!= ABOUT_TEST
)
2114 CHECK_CALLED(OnDataAvailable
);
2115 CHECK_CALLED(OnStopBinding
);
2118 ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
2119 ok(IBindCtx_Release(bctx
) == 0, "bctx should be destroyed here\n");
2121 if(test_protocol
== HTTP_TEST
)
2122 http_is_first
= FALSE
;
2125 static void test_BindToObject(int protocol
, BOOL emul
)
2129 LPOLESTR display_name
;
2133 IUnknown
*unk
= (IUnknown
*)0x00ff00ff;
2136 init_bind_test(protocol
, emul
, TRUE
, TYMED_ISTREAM
);
2139 CoRegisterClassObject(&CLSID_HTMLDocument
, (IUnknown
*)&mime_cf
,
2140 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, ®id
);
2142 SET_EXPECT(QueryInterface_IServiceProvider
);
2143 hres
= CreateAsyncBindCtx(0, &objbsc
, NULL
, &bctx
);
2144 ok(SUCCEEDED(hres
), "CreateAsyncBindCtx failed: %08x\n\n", hres
);
2145 CHECK_CALLED(QueryInterface_IServiceProvider
);
2149 hres
= CreateURLMoniker(NULL
, urls
[test_protocol
], &mon
);
2150 ok(SUCCEEDED(hres
), "failed to create moniker: %08x\n", hres
);
2152 IBindCtx_Release(bctx
);
2156 if(test_protocol
== FILE_TEST
&& INDEX_HTML
[7] == '/')
2157 memmove(INDEX_HTML
+7, INDEX_HTML
+8, lstrlenW(INDEX_HTML
+7)*sizeof(WCHAR
));
2159 hres
= IMoniker_QueryInterface(mon
, &IID_IBinding
, (void**)&bind
);
2160 ok(hres
== E_NOINTERFACE
, "IMoniker should not have IBinding interface\n");
2162 IBinding_Release(bind
);
2164 hres
= IMoniker_GetDisplayName(mon
, bctx
, NULL
, &display_name
);
2165 ok(hres
== S_OK
, "GetDisplayName failed %08x\n", hres
);
2166 ok(!lstrcmpW(display_name
, urls
[test_protocol
]), "GetDisplayName got wrong name\n");
2168 SET_EXPECT(Obj_GetBindInfo
);
2169 SET_EXPECT(QueryInterface_IInternetProtocol
);
2170 if(!emulate_protocol
)
2171 SET_EXPECT(QueryService_IInternetProtocol
);
2172 SET_EXPECT(Obj_OnStartBinding
);
2173 if(emulate_protocol
) {
2175 if(test_protocol
== HTTP_TEST
)
2176 SET_EXPECT(Terminate
);
2177 SET_EXPECT(UnlockRequest
);
2179 if(test_protocol
== HTTP_TEST
) {
2180 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2181 SET_EXPECT(BeginningTransaction
);
2182 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
2183 SET_EXPECT(GetRootSecurityId
);
2184 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
2185 SET_EXPECT(Obj_OnProgress_CONNECTING
);
2187 if(test_protocol
== HTTP_TEST
|| test_protocol
== FILE_TEST
)
2188 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
2189 if(test_protocol
== HTTP_TEST
)
2190 SET_EXPECT(OnResponse
);
2191 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
2192 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
2193 if(test_protocol
== FILE_TEST
)
2194 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
2195 if(test_protocol
== HTTP_TEST
)
2196 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
2197 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
2198 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
2199 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
2200 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
2201 SET_EXPECT(OnObjectAvailable
);
2202 SET_EXPECT(Obj_OnStopBinding
);
2205 hres
= IMoniker_BindToObject(mon
, bctx
, NULL
, &IID_IUnknown
, (void**)&unk
);
2207 if (test_protocol
== HTTP_TEST
&& hres
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
2209 trace( "Network unreachable, skipping tests\n" );
2213 /* no point testing the calls if binding didn't even work */
2214 if (FAILED(hres
)) return;
2216 if(bindf
& BINDF_ASYNCHRONOUS
) {
2217 ok(hres
== MK_S_ASYNCHRONOUS
, "IMoniker_BindToObject failed: %08x\n", hres
);
2218 ok(unk
== NULL
, "istr should be NULL\n");
2220 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
2221 ok(unk
!= NULL
, "unk == NULL\n");
2223 ok(unk
== (IUnknown
*)&PersistMoniker
, "unk != PersistMoniker\n");
2226 IUnknown_Release(unk
);
2228 while((bindf
& BINDF_ASYNCHRONOUS
) &&
2229 !((!emul
|| stopped_binding
) && stopped_obj_binding
) && GetMessage(&msg
,NULL
,0,0)) {
2230 TranslateMessage(&msg
);
2231 DispatchMessage(&msg
);
2234 CHECK_CALLED(Obj_GetBindInfo
);
2235 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2236 if(!emulate_protocol
)
2237 CHECK_CALLED(QueryService_IInternetProtocol
);
2238 CHECK_CALLED(Obj_OnStartBinding
);
2239 if(emulate_protocol
) {
2240 CHECK_CALLED(Start
);
2241 if(test_protocol
== HTTP_TEST
)
2242 CHECK_CALLED(Terminate
);
2243 CHECK_CALLED(UnlockRequest
);
2245 if(test_protocol
== HTTP_TEST
) {
2246 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
2247 CHECK_CALLED(BeginningTransaction
);
2248 /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
2249 * called on WinXP but not on Win98 */
2250 CLEAR_CALLED(QueryInterface_IHttpNegotiate2
);
2251 CLEAR_CALLED(GetRootSecurityId
);
2253 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
2254 CHECK_CALLED(Obj_OnProgress_CONNECTING
);
2256 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
2257 CHECK_NOT_CALLED(Obj_OnProgress_CONNECTING
);
2260 if(test_protocol
== HTTP_TEST
|| test_protocol
== FILE_TEST
) {
2261 if(urls
[test_protocol
] == SHORT_RESPONSE_URL
)
2262 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST
);
2264 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
2266 if(test_protocol
== HTTP_TEST
)
2267 CHECK_CALLED(OnResponse
);
2268 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
2269 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
2270 if(test_protocol
== FILE_TEST
)
2271 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
2272 if(test_protocol
== HTTP_TEST
)
2273 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
2274 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA
);
2275 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
2276 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
2277 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
2278 CHECK_CALLED(OnObjectAvailable
);
2279 CHECK_CALLED(Obj_OnStopBinding
);
2282 if(test_protocol
!= HTTP_TEST
|| emul
|| urls
[test_protocol
] == SHORT_RESPONSE_URL
) {
2283 ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
2284 ok(IBindCtx_Release(bctx
) == 0, "bctx should be destroyed here\n");
2286 ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
2287 ok(IBindCtx_Release(bctx
) == 0, "bctx should be destroyed here\n");
2291 CoRevokeClassObject(regid
);
2293 if(test_protocol
== HTTP_TEST
)
2294 http_is_first
= FALSE
;
2297 static void set_file_url(void)
2301 static const WCHAR wszFile
[] = {'f','i','l','e',':','/','/'};
2303 memcpy(INDEX_HTML
, wszFile
, sizeof(wszFile
));
2304 len
= sizeof(wszFile
)/sizeof(WCHAR
);
2305 INDEX_HTML
[len
++] = '/';
2306 len
+= GetCurrentDirectoryW(sizeof(INDEX_HTML
)/sizeof(WCHAR
)-len
, INDEX_HTML
+len
);
2307 INDEX_HTML
[len
++] = '\\';
2308 memcpy(INDEX_HTML
+len
, wszIndexHtml
, sizeof(wszIndexHtml
));
2311 static void create_file(void)
2316 static const char html_doc
[] = "<HTML></HTML>";
2318 file
= CreateFileW(wszIndexHtml
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
2319 FILE_ATTRIBUTE_NORMAL
, NULL
);
2320 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
2321 if(file
== INVALID_HANDLE_VALUE
)
2324 WriteFile(file
, html_doc
, sizeof(html_doc
)-1, &size
, NULL
);
2330 static void test_ReportResult(HRESULT exhres
)
2332 IMoniker
*mon
= NULL
;
2333 IBindCtx
*bctx
= NULL
;
2334 IUnknown
*unk
= (void*)0xdeadbeef;
2337 init_bind_test(ABOUT_TEST
, TRUE
, FALSE
, TYMED_ISTREAM
);
2338 binding_hres
= exhres
;
2340 hres
= CreateURLMoniker(NULL
, ABOUT_BLANK
, &mon
);
2341 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
2343 SET_EXPECT(QueryInterface_IServiceProvider
);
2344 hres
= CreateAsyncBindCtx(0, &bsc
, NULL
, &bctx
);
2345 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
2346 CHECK_CALLED(QueryInterface_IServiceProvider
);
2348 SET_EXPECT(GetBindInfo
);
2349 SET_EXPECT(QueryInterface_IInternetProtocol
);
2350 SET_EXPECT(OnStartBinding
);
2353 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&unk
);
2354 if(SUCCEEDED(exhres
))
2355 ok(hres
== S_OK
|| hres
== MK_S_ASYNCHRONOUS
, "BindToStorage failed: %08x\n", hres
);
2357 ok(hres
== exhres
|| hres
== MK_S_ASYNCHRONOUS
,
2358 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres
, exhres
);
2360 CHECK_CALLED(GetBindInfo
);
2361 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2362 CHECK_CALLED(OnStartBinding
);
2363 CHECK_CALLED(Start
);
2365 ok(unk
== NULL
, "unk=%p\n", unk
);
2367 IBindCtx_Release(bctx
);
2368 IMoniker_Release(mon
);
2371 static void test_BindToStorage_fail(void)
2373 IMoniker
*mon
= NULL
;
2374 IBindCtx
*bctx
= NULL
;
2378 hres
= CreateURLMoniker(NULL
, ABOUT_BLANK
, &mon
);
2379 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
2383 hres
= CreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
2384 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
2386 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&unk
);
2387 ok(hres
== MK_E_SYNTAX
|| hres
== INET_E_DATA_NOT_AVAILABLE
,
2388 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres
);
2390 IBindCtx_Release(bctx
);
2392 IMoniker_Release(mon
);
2394 test_ReportResult(E_NOTIMPL
);
2395 test_ReportResult(S_FALSE
);
2400 complete_event
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2401 complete_event2
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2402 thread_id
= GetCurrentThreadId();
2405 test_CreateAsyncBindCtx();
2406 test_CreateAsyncBindCtxEx();
2407 test_RegisterBindStatusCallback();
2408 test_BindToStorage_fail();
2410 trace("synchronous http test (COM not initialised)...\n");
2411 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2415 trace("synchronous http test...\n");
2416 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2418 trace("synchronous http test (to object)...\n");
2419 test_BindToObject(HTTP_TEST
, FALSE
);
2421 trace("synchronous file test...\n");
2423 test_BindToStorage(FILE_TEST
, FALSE
, TYMED_ISTREAM
);
2425 trace("synchronous file test (to object)...\n");
2426 test_BindToObject(FILE_TEST
, FALSE
);
2427 DeleteFileW(wszIndexHtml
);
2429 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
2431 trace("http test...\n");
2432 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2434 trace("http test (to file)...\n");
2435 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_FILE
);
2437 trace("http test (to object)...\n");
2438 test_BindToObject(HTTP_TEST
, FALSE
);
2440 trace("http test (short response)...\n");
2441 http_is_first
= TRUE
;
2442 urls
[HTTP_TEST
] = SHORT_RESPONSE_URL
;
2443 test_BindToStorage(HTTP_TEST
, FALSE
, TYMED_ISTREAM
);
2445 trace("http test (short response, to object)...\n");
2446 test_BindToObject(HTTP_TEST
, FALSE
);
2448 trace("emulated http test...\n");
2449 test_BindToStorage(HTTP_TEST
, TRUE
, TYMED_ISTREAM
);
2451 trace("emulated http test (to object)...\n");
2452 test_BindToObject(HTTP_TEST
, TRUE
);
2454 trace("emulated http test (to file)...\n");
2455 test_BindToStorage(HTTP_TEST
, TRUE
, TYMED_FILE
);
2457 trace("about test...\n");
2458 test_BindToStorage(ABOUT_TEST
, FALSE
, TYMED_ISTREAM
);
2460 trace("about test (to file)...\n");
2461 test_BindToStorage(ABOUT_TEST
, FALSE
, TYMED_FILE
);
2463 trace("about test (to object)...\n");
2464 test_BindToObject(ABOUT_TEST
, FALSE
);
2466 trace("emulated about test...\n");
2467 test_BindToStorage(ABOUT_TEST
, TRUE
, TYMED_ISTREAM
);
2469 trace("emulated about test (to file)...\n");
2470 test_BindToStorage(ABOUT_TEST
, TRUE
, TYMED_FILE
);
2472 trace("emulated about test (to object)...\n");
2473 test_BindToObject(ABOUT_TEST
, TRUE
);
2475 trace("file test...\n");
2477 test_BindToStorage(FILE_TEST
, FALSE
, TYMED_ISTREAM
);
2479 trace("file test (to file)...\n");
2480 test_BindToStorage(FILE_TEST
, FALSE
, TYMED_FILE
);
2482 trace("file test (to object)...\n");
2483 test_BindToObject(FILE_TEST
, FALSE
);
2484 DeleteFileW(wszIndexHtml
);
2486 trace("emulated file test...\n");
2488 test_BindToStorage(FILE_TEST
, TRUE
, TYMED_ISTREAM
);
2490 trace("emulated file test (to file)...\n");
2491 test_BindToStorage(FILE_TEST
, TRUE
, TYMED_FILE
);
2493 trace("emulated file test (to object)...\n");
2494 test_BindToObject(FILE_TEST
, TRUE
);
2496 trace("emulated its test...\n");
2497 test_BindToStorage(ITS_TEST
, TRUE
, TYMED_ISTREAM
);
2499 trace("emulated its test (to file)...\n");
2500 test_BindToStorage(ITS_TEST
, TRUE
, TYMED_FILE
);
2502 trace("emulated mk test...\n");
2503 test_BindToStorage(MK_TEST
, TRUE
, TYMED_ISTREAM
);
2505 trace("test failures...\n");
2506 test_BindToStorage_fail();
2508 CloseHandle(complete_event
);
2509 CloseHandle(complete_event2
);