From 0d27b740b3b3c56ebba4e57ca2c6a92add3eef76 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 4 Oct 2010 14:00:48 +0200 Subject: [PATCH] urlmon: Added Abort support to BindProtocol. --- dlls/urlmon/bindprot.c | 15 +++++++++++---- dlls/urlmon/tests/protocol.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/dlls/urlmon/bindprot.c b/dlls/urlmon/bindprot.c index 01443e37856..3e1fb582d9f 100644 --- a/dlls/urlmon/bindprot.c +++ b/dlls/urlmon/bindprot.c @@ -423,8 +423,10 @@ static HRESULT WINAPI BindProtocol_Abort(IInternetProtocol *iface, HRESULT hrRea DWORD dwOptions) { BindProtocol *This = PROTOCOL_THIS(iface); - FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); - return E_NOTIMPL; + + TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + + return IInternetProtocol_Abort(This->protocol_handler, hrReason, dwOptions); } static HRESULT WINAPI BindProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) @@ -653,8 +655,13 @@ static HRESULT WINAPI ProtocolHandler_Abort(IInternetProtocol *iface, HRESULT hr DWORD dwOptions) { BindProtocol *This = PROTOCOLHANDLER_THIS(iface); - FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); - return E_NOTIMPL; + + TRACE("(%p)->(%08x %08x)\n", This, hrReason, dwOptions); + + if(This->protocol && !This->reported_result) + return IInternetProtocol_Abort(This->protocol, hrReason, dwOptions); + + return S_OK; } static HRESULT WINAPI ProtocolHandler_Terminate(IInternetProtocol *iface, DWORD dwOptions) diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c index a116cf39e14..15c3bc44e81 100644 --- a/dlls/urlmon/tests/protocol.c +++ b/dlls/urlmon/tests/protocol.c @@ -108,6 +108,7 @@ DEFINE_EXPECT(Read2); DEFINE_EXPECT(SetPriority); DEFINE_EXPECT(LockRequest); DEFINE_EXPECT(UnlockRequest); +DEFINE_EXPECT(Abort); DEFINE_EXPECT(MimeFilter_CreateInstance); DEFINE_EXPECT(MimeFilter_Start); DEFINE_EXPECT(MimeFilter_ReportProgress); @@ -1159,8 +1160,16 @@ static ULONG WINAPI Protocol_Release(IInternetProtocol *iface) static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason, DWORD dwOptions) { - ok(0, "unexpected call\n"); - return E_NOTIMPL; + HRESULT hres; + + CHECK_EXPECT(Abort); + + SET_EXPECT(ReportResult); + hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL); + ok(hres == S_OK, "ReportResult failed: %08x\n", hres); + CHECK_CALLED(ReportResult); + + return S_OK; } static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface) @@ -1262,6 +1271,11 @@ static DWORD WINAPI thread_proc(PVOID arg) else CHECK_CALLED(Switch); + if(test_abort) { + SetEvent(event_complete); + return 0; + } + prot_state = 2; if(mimefilter_test) SET_EXPECT(MimeFilter_Switch); @@ -2999,6 +3013,18 @@ static void test_CreateBinding(void) IInternetBindInfo_Release(prot_bind_info); IInternetProtocol_Release(protocol); + hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0); + ok(hres == S_OK, "CreateBinding failed: %08x\n", hres); + ok(protocol != NULL, "protocol == NULL\n"); + + hres = IInternetProtocol_Abort(protocol, E_ABORT, 0); + ok(hres == S_OK, "Abort failed: %08x\n", hres); + + hres = IInternetProtocol_Abort(protocol, E_FAIL, 0); + ok(hres == S_OK, "Abort failed: %08x\n", hres); + + IInternetProtocol_Release(protocol); + hres = IInternetSession_UnregisterNameSpace(session, &ClassFactory, wsz_test); ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres); @@ -3064,6 +3090,17 @@ static void test_binding(int prot, DWORD grf_pi, DWORD test_flags) IInternetProtocol_Continue(protocol, pdata); CHECK_CALLED(Continue); } + if(test_abort && prot_state == 2) { + SET_EXPECT(Abort); + hres = IInternetProtocol_Abort(protocol, E_ABORT, 0); + ok(hres == S_OK, "Abort failed: %08x\n", hres); + CHECK_CALLED(Abort); + + hres = IInternetProtocol_Abort(protocol, E_ABORT, 0); + ok(hres == S_OK, "Abort failed: %08x\n", hres); + SetEvent(event_complete2); + break; + } SetEvent(event_complete2); } if(direct_read) @@ -3179,6 +3216,8 @@ START_TEST(protocol) test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER); trace("Testing http binding (mime verification, emulate prot, direct read)...\n"); test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_DIRECT_READ); + trace("Testing http binding (mime verification, emulate prot, abort)...\n"); + test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_ABORT); CloseHandle(event_complete); CloseHandle(event_complete2); -- 2.11.4.GIT