static ULONG WINAPI BindStatusCallback_Release(IBindStatusCallback *iface) { BindStatusCallback *This = STATUSCLB_THIS(iface); LONG ref = InterlockedDecrement(&This->ref); TRACE("(%p) ref = %d\n", This, ref); if(!ref) { if(This->serv_prov) IServiceProvider_Release(This->serv_prov); if(This->http_negotiate) IHttpNegotiate_Release(This->http_negotiate); if(This->http_negotiate2) IHttpNegotiate2_Release(This->http_negotiate2); if(This->authenticate) IAuthenticate_Release(This->authenticate); IBindStatusCallback_Release(This->callback); heap_free(This); } return ref; }
static void test_HlinkCreateExtensionServices(void) { IAuthenticate *authenticate; IHttpNegotiate *http_negotiate; LPWSTR password, username, headers; HWND hwnd; HRESULT hres; static const WCHAR usernameW[] = {'u','s','e','r',0}; static const WCHAR passwordW[] = {'p','a','s','s',0}; static const WCHAR headersW[] = {'h','e','a','d','e','r','s',0}; static const WCHAR headersexW[] = {'h','e','a','d','e','r','s','\r','\n',0}; hres = HlinkCreateExtensionServices(NULL, NULL, NULL, NULL, NULL, &IID_IAuthenticate, (void**)&authenticate); ok(hres == S_OK, "HlinkCreateExtensionServices failed: %08x\n", hres); ok(authenticate != NULL, "HlinkCreateExtensionServices returned NULL\n"); password = username = (void*)0xdeadbeef; hwnd = (void*)0xdeadbeef; hres = IAuthenticate_Authenticate(authenticate, &hwnd, &username, &password); ok(hres == S_OK, "Authenticate failed: %08x\n", hres); ok(!hwnd, "hwnd != NULL\n"); ok(!username, "username != NULL\n"); ok(!password, "password != NULL\n"); hres = IAuthenticate_QueryInterface(authenticate, &IID_IHttpNegotiate, (void**)&http_negotiate); ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres); headers = (void*)0xdeadbeef; hres = IHttpNegotiate_BeginningTransaction(http_negotiate, (void*)0xdeadbeef, (void*)0xdeadbeef, 0, &headers); ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres); ok(headers == NULL, "headers != NULL\n"); hres = IHttpNegotiate_BeginningTransaction(http_negotiate, (void*)0xdeadbeef, (void*)0xdeadbeef, 0, NULL); ok(hres == E_INVALIDARG, "BeginningTransaction failed: %08x, expected E_INVALIDARG\n", hres); headers = (void*)0xdeadbeef; hres = IHttpNegotiate_OnResponse(http_negotiate, 200, (void*)0xdeadbeef, (void*)0xdeadbeef, &headers); ok(hres == S_OK, "OnResponse failed: %08x\n", hres); ok(headers == NULL, "headers != NULL\n"); IHttpNegotiate_Release(http_negotiate); IAuthenticate_Release(authenticate); hres = HlinkCreateExtensionServices(headersW, (HWND)0xfefefefe, usernameW, passwordW, NULL, &IID_IAuthenticate, (void**)&authenticate); ok(hres == S_OK, "HlinkCreateExtensionServices failed: %08x\n", hres); ok(authenticate != NULL, "HlinkCreateExtensionServices returned NULL\n"); password = username = NULL; hwnd = NULL; hres = IAuthenticate_Authenticate(authenticate, &hwnd, &username, &password); ok(hres == S_OK, "Authenticate failed: %08x\n", hres); ok(hwnd == (HWND)0xfefefefe, "hwnd=%p\n", hwnd); ok(!lstrcmpW(username, usernameW), "unexpected username\n"); ok(!lstrcmpW(password, passwordW), "unexpected password\n"); CoTaskMemFree(username); CoTaskMemFree(password); password = username = (void*)0xdeadbeef; hwnd = (void*)0xdeadbeef; hres = IAuthenticate_Authenticate(authenticate, &hwnd, NULL, &password); ok(hres == E_INVALIDARG, "Authenticate failed: %08x\n", hres); ok(password == (void*)0xdeadbeef, "password = %p\n", password); ok(hwnd == (void*)0xdeadbeef, "hwnd = %p\n", hwnd); hres = IAuthenticate_QueryInterface(authenticate, &IID_IHttpNegotiate, (void**)&http_negotiate); ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres); headers = (void*)0xdeadbeef; hres = IHttpNegotiate_BeginningTransaction(http_negotiate, (void*)0xdeadbeef, (void*)0xdeadbeef, 0, &headers); ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres); ok(!lstrcmpW(headers, headersexW), "unexpected headers \"%s\"\n", debugstr_w(headers)); CoTaskMemFree(headers); headers = (void*)0xdeadbeef; hres = IHttpNegotiate_OnResponse(http_negotiate, 200, (void*)0xdeadbeef, (void*)0xdeadbeef, &headers); ok(hres == S_OK, "OnResponse failed: %08x\n", hres); ok(headers == NULL, "unexpected headers \"%s\"\n", debugstr_w(headers)); IHttpNegotiate_Release(http_negotiate); IAuthenticate_Release(authenticate); }