Jacek Caban : urlmon: Added more tests.

Alexandre Julliard julliard at winehq.org
Mon Sep 3 13:19:12 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Sep  3 13:59:08 2012 +0200

urlmon: Added more tests.

---

 dlls/urlmon/tests/url.c |   55 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/dlls/urlmon/tests/url.c b/dlls/urlmon/tests/url.c
index 5be3f02..a929ace 100644
--- a/dlls/urlmon/tests/url.c
+++ b/dlls/urlmon/tests/url.c
@@ -218,6 +218,7 @@ static LPCWSTR urls[] = {
     MK_URL,
     https_urlW,
     ftp_urlW,
+    winetest_urlW,
     winetest_urlW
 };
 
@@ -231,7 +232,8 @@ static enum {
     MK_TEST,
     HTTPS_TEST,
     FTP_TEST,
-    WINETEST_TEST
+    WINETEST_TEST,
+    WINETEST_SYNC_TEST
 } test_protocol;
 
 static enum {
@@ -705,6 +707,9 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
             CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
         else
             CHECK_CALLED(OnProgress_SENDINGREQUEST);
+    case WINETEST_SYNC_TEST:
+        IInternetProtocolSink_AddRef(pOIProtSink);
+        protocol_sink = pOIProtSink;
     default:
         break;
     }
@@ -848,9 +853,14 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
             CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
         else
             CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
+    }else if(test_protocol == WINETEST_SYNC_TEST) {
+        SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
+        hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
+        ok(hres == S_OK,
+           "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
+        CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
     }else {
-        hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
-                BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
+        hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
         ok(hres == S_OK,
            "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
     }
@@ -862,7 +872,7 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
 
     SET_EXPECT(Read);
     if(bind_to_object) {
-        if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
+        if(test_protocol != FILE_TEST && test_protocol != MK_TEST && test_protocol != WINETEST_SYNC_TEST)
             SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
         SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
         if(test_protocol == FILE_TEST)
@@ -887,7 +897,8 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         SET_EXPECT(LockRequest);
         if(!filedwl_api)
             SET_EXPECT(OnDataAvailable);
-        SET_EXPECT(OnStopBinding);
+        if(test_protocol != WINETEST_SYNC_TEST) /* Set in Read after ReportResult call */
+            SET_EXPECT(OnStopBinding);
     }
 
     hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
@@ -911,7 +922,7 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         CHECK_CALLED(OnObjectAvailable);
         CHECK_CALLED(Obj_OnStopBinding);
     }else {
-        if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
+        if(test_protocol != FILE_TEST && test_protocol != MK_TEST && test_protocol != WINETEST_SYNC_TEST)
             CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
         CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
         if(test_protocol == FILE_TEST)
@@ -928,17 +939,19 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
         ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
         CHECK_CALLED(Read);
-    }else if(!bind_to_object && test_protocol == ABOUT_TEST) {
+    }else if(!bind_to_object && test_protocol == FILE_TEST) {
         SET_EXPECT(Read);
         hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
         ok(hres == S_OK, "ReportData failed: %08x\n", hres);
         CHECK_CALLED(Read);
     }
 
-    SET_EXPECT(Terminate);
-    hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
-    ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
-    CHECK_CALLED(Terminate);
+    if(test_protocol != WINETEST_SYNC_TEST) {
+        SET_EXPECT(Terminate);
+        hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
+        ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
+        CHECK_CALLED(Terminate);
+    }
 
     return S_OK;
 }
@@ -1119,6 +1132,8 @@ static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
         ULONG cb, ULONG *pcbRead)
 {
+    HRESULT hres;
+
     static const char data[] = "<HTML></HTML>";
 
     CHECK_EXPECT2(Read);
@@ -1139,8 +1154,6 @@ static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
     }
 
     if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
-        HRESULT hres;
-
         static int pending = TRUE;
 
         pending = !pending;
@@ -1184,6 +1197,13 @@ static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
         return S_FALSE;
     }
 
+    if(test_protocol == WINETEST_SYNC_TEST) {
+        hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
+        ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
+
+        SET_EXPECT(OnStopBinding);
+    }
+
     ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
     read += *pcbRead = sizeof(data)-1;
     memcpy(pv, data, sizeof(data));
@@ -2917,7 +2937,8 @@ static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
         if(is_urlmon_protocol(test_protocol))
             SET_EXPECT(SetPriority);
         SET_EXPECT(Start);
-        if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
+        if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST
+           || test_protocol == WINETEST_SYNC_TEST)
             SET_EXPECT(Terminate);
         if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
             SET_EXPECT(UnlockRequest);
@@ -3057,7 +3078,8 @@ static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
         if(is_urlmon_protocol(test_protocol))
             CHECK_CALLED(SetPriority);
         CHECK_CALLED(Start);
-        if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
+        if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST
+           || test_protocol == WINETEST_SYNC_TEST) {
             if(tymed == TYMED_FILE)
                 CLEAR_CALLED(Read);
             CHECK_CALLED(Terminate);
@@ -3959,6 +3981,9 @@ START_TEST(url)
         trace("emulated about test (to object)...\n");
         test_BindToObject(ABOUT_TEST, BINDTEST_EMULATE);
 
+        trace("emulalated test reporting result in read...\n");
+        test_BindToStorage(WINETEST_SYNC_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
+
         trace("file test...\n");
         test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
 




More information about the wine-cvs mailing list