Misha Koshelev : urlmon/tests: Add tests for calls to IHttpNegotiate interfaces as exposed by IBindStatusCallback .

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 24 07:06:20 CDT 2007


Module: wine
Branch: master
Commit: 8f78c71cb6e7e2bc5bb318cf4cd37404f363d619
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8f78c71cb6e7e2bc5bb318cf4cd37404f363d619

Author: Misha Koshelev <mk144210 at bcm.edu>
Date:   Mon Jul 23 20:33:08 2007 -0500

urlmon/tests: Add tests for calls to IHttpNegotiate interfaces as exposed by IBindStatusCallback.

Add more tests for specific arguments passed to IHttpNegotiate and IHttpNegotiate2. Note that
for OnResponse pszAdditionalHeaders is NULL when called directly from IInternetProtocol (for
example as seen in our protocol tests) but non-NULL when these interfaces are exposed by
IBindStatusCallback as seen here. Tests conform on Win98 and Winxp.

---

 dlls/urlmon/tests/url.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 102 insertions(+), 1 deletions(-)

diff --git a/dlls/urlmon/tests/url.c b/dlls/urlmon/tests/url.c
index 7aa6ead..187fb03 100644
--- a/dlls/urlmon/tests/url.c
+++ b/dlls/urlmon/tests/url.c
@@ -67,7 +67,10 @@
 
 DEFINE_EXPECT(QueryInterface_IServiceProvider);
 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
+DEFINE_EXPECT(BeginningTransaction);
+DEFINE_EXPECT(OnResponse);
 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
+DEFINE_EXPECT(GetRootSecurityId);
 DEFINE_EXPECT(GetBindInfo);
 DEFINE_EXPECT(OnStartBinding);
 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
@@ -374,6 +377,92 @@ static const IInternetProtocolVtbl ProtocolVtbl = {
 
 static IInternetProtocol Protocol = { &ProtocolVtbl };
 
+static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
+{
+    if(IsEqualGUID(&IID_IUnknown, riid)
+            || IsEqualGUID(&IID_IHttpNegotiate, riid)
+            || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
+        *ppv = iface;
+        return S_OK;
+    }
+
+    ok(0, "unexpected call\n");
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
+{
+    return 2;
+}
+
+static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
+{
+    return 1;
+}
+
+static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
+        LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
+{
+    CHECK_EXPECT(BeginningTransaction);
+
+    ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
+    ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
+    ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
+    if(pszAdditionalHeaders)
+        ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
+
+    return S_OK;
+}
+
+static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
+        LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
+{
+    CHECK_EXPECT(OnResponse);
+
+    ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
+    ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
+    ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
+    /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
+    ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
+    if(pszAdditionalRequestHeaders)
+        ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
+
+    return S_OK;
+}
+
+static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
+        BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
+{
+    static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
+
+    CHECK_EXPECT(GetRootSecurityId);
+
+    ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
+    ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
+    ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
+
+    if(pcbSecurityId) {
+        ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
+        *pcbSecurityId = sizeof(sec_id);
+    }
+
+    if(pbSecurityId)
+        memcpy(pbSecurityId, sec_id, sizeof(sec_id));
+
+    return E_FAIL;
+}
+
+static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
+    HttpNegotiate_QueryInterface,
+    HttpNegotiate_AddRef,
+    HttpNegotiate_Release,
+    HttpNegotiate_BeginningTransaction,
+    HttpNegotiate_OnResponse,
+    HttpNegotiate_GetRootSecurityId
+};
+
+static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
+
 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFIID riid, void **ppv)
 {
     if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
@@ -391,10 +480,14 @@ static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallback *iface, REFII
     else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
     {
         CHECK_EXPECT(QueryInterface_IHttpNegotiate);
+        *ppv = &HttpNegotiate;
+        return S_OK;
     }
     else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
     {
         CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
+        *ppv = &HttpNegotiate;
+        return S_OK;
     }
 
     return E_NOINTERFACE;
@@ -724,12 +817,16 @@ static void test_BindToStorage(int protocol, BOOL emul)
     }else {
         if(test_protocol == HTTP_TEST) {
             SET_EXPECT(QueryInterface_IHttpNegotiate);
+            SET_EXPECT(BeginningTransaction);
             SET_EXPECT(QueryInterface_IHttpNegotiate2);
+            SET_EXPECT(GetRootSecurityId);
             SET_EXPECT(OnProgress_FINDINGRESOURCE);
             SET_EXPECT(OnProgress_CONNECTING);
         }
         if(test_protocol == HTTP_TEST || test_protocol == FILE_TEST)
             SET_EXPECT(OnProgress_SENDINGREQUEST);
+        if(test_protocol == HTTP_TEST)
+            SET_EXPECT(OnResponse);
         SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
         SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
         if(test_protocol == HTTP_TEST)
@@ -771,11 +868,15 @@ static void test_BindToStorage(int protocol, BOOL emul)
     }else {
         if(test_protocol == HTTP_TEST) {
             todo_wine CHECK_CALLED(QueryInterface_IHttpNegotiate);
-            /* QueryInterface_IHttpNegotiate2 called on WinXP but not on Win98 */
+            todo_wine CHECK_CALLED(BeginningTransaction);
+            /* QueryInterface_IHttpNegotiate2 and GetRootSecurityId
+             * called on WinXP but not on Win98 */
             CLEAR_CALLED(QueryInterface_IHttpNegotiate2);
+            CLEAR_CALLED(GetRootSecurityId);
             CHECK_CALLED(OnProgress_FINDINGRESOURCE);
             CHECK_CALLED(OnProgress_CONNECTING);
             CHECK_CALLED(OnProgress_SENDINGREQUEST);
+            todo_wine CHECK_CALLED(OnResponse);
             todo_wine { CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); }
         }else {
             todo_wine CHECK_NOT_CALLED(QueryInterface_IServiceProvider);




More information about the wine-cvs mailing list