Changeset 140668 in webkit


Ignore:
Timestamp:
Jan 24, 2013 2:12:56 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] move most WebViewHost printf calls to WebTestProxy
https://bugs.webkit.org/show_bug.cgi?id=107553

Patch by Dan Carney <dcarney@google.com> on 2013-01-24
Reviewed by Jochen Eisinger.

  • DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:

(WebKit):
(WebTestProxyBase):
(WebTestRunner::WebTestProxy::unableToImplementPolicyWithError):
(WebTestRunner::WebTestProxy::didAddMessageToConsole):
(WebTestRunner::WebTestProxy::runModalAlertDialog):
(WebTestRunner::WebTestProxy::runModalConfirmDialog):
(WebTestRunner::WebTestProxy::runModalPromptDialog):
(WebTestRunner::WebTestProxy::runModalBeforeUnloadDialog):

  • DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:

(WebTestRunner::WebTestProxyBase::WebTestProxyBase):
(WebTestRunner::WebTestProxyBase::reset):
(WebTestRunner::WebTestProxyBase::setLogConsoleOutput):
(WebTestRunner):
(WebTestRunner::WebTestProxyBase::unableToImplementPolicyWithError):
(WebTestRunner::WebTestProxyBase::didAddMessageToConsole):
(WebTestRunner::WebTestProxyBase::runModalAlertDialog):
(WebTestRunner::WebTestProxyBase::runModalConfirmDialog):
(WebTestRunner::WebTestProxyBase::runModalPromptDialog):
(WebTestRunner::WebTestProxyBase::runModalBeforeUnloadDialog):

  • DumpRenderTree/chromium/TestShell.cpp:

(TestShell::showDevTools):

  • DumpRenderTree/chromium/WebViewHost.cpp:

(WebViewHost::didAddMessageToConsole):
(WebViewHost::runModalAlertDialog):
(WebViewHost::runModalConfirmDialog):
(WebViewHost::runModalPromptDialog):
(WebViewHost::runModalBeforeUnloadDialog):
(WebViewHost::unableToImplementPolicyWithError):
(WebViewHost::reset):

  • DumpRenderTree/chromium/WebViewHost.h:

(WebViewHost):

Location:
trunk/Tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r140653 r140668  
     12013-01-24  Dan Carney  <dcarney@google.com>
     2
     3        [chromium] move most WebViewHost printf calls to WebTestProxy
     4        https://bugs.webkit.org/show_bug.cgi?id=107553
     5
     6        Reviewed by Jochen Eisinger.
     7
     8        * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
     9        (WebKit):
     10        (WebTestProxyBase):
     11        (WebTestRunner::WebTestProxy::unableToImplementPolicyWithError):
     12        (WebTestRunner::WebTestProxy::didAddMessageToConsole):
     13        (WebTestRunner::WebTestProxy::runModalAlertDialog):
     14        (WebTestRunner::WebTestProxy::runModalConfirmDialog):
     15        (WebTestRunner::WebTestProxy::runModalPromptDialog):
     16        (WebTestRunner::WebTestProxy::runModalBeforeUnloadDialog):
     17        * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
     18        (WebTestRunner::WebTestProxyBase::WebTestProxyBase):
     19        (WebTestRunner::WebTestProxyBase::reset):
     20        (WebTestRunner::WebTestProxyBase::setLogConsoleOutput):
     21        (WebTestRunner):
     22        (WebTestRunner::WebTestProxyBase::unableToImplementPolicyWithError):
     23        (WebTestRunner::WebTestProxyBase::didAddMessageToConsole):
     24        (WebTestRunner::WebTestProxyBase::runModalAlertDialog):
     25        (WebTestRunner::WebTestProxyBase::runModalConfirmDialog):
     26        (WebTestRunner::WebTestProxyBase::runModalPromptDialog):
     27        (WebTestRunner::WebTestProxyBase::runModalBeforeUnloadDialog):
     28        * DumpRenderTree/chromium/TestShell.cpp:
     29        (TestShell::showDevTools):
     30        * DumpRenderTree/chromium/WebViewHost.cpp:
     31        (WebViewHost::didAddMessageToConsole):
     32        (WebViewHost::runModalAlertDialog):
     33        (WebViewHost::runModalConfirmDialog):
     34        (WebViewHost::runModalPromptDialog):
     35        (WebViewHost::runModalBeforeUnloadDialog):
     36        (WebViewHost::unableToImplementPolicyWithError):
     37        (WebViewHost::reset):
     38        * DumpRenderTree/chromium/WebViewHost.h:
     39        (WebViewHost):
     40
    1412013-01-23  Mark Pilgrim  <pilgrim@chromium.org>
    242
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h

    r140396 r140668  
    4242#include <string>
    4343
     44#define TEST_RUNNER_MOVED_PRINTING 1
     45
    4446namespace WebKit {
    4547class WebAccessibilityObject;
     
    6062class WebURLResponse;
    6163class WebView;
     64struct WebConsoleMessage;
    6265struct WebPoint;
    6366struct WebSize;
     
    8487    void setPaintRect(const WebKit::WebRect&);
    8588    WebKit::WebRect paintRect() const;
     89
     90    void setLogConsoleOutput(bool enabled);
    8691
    8792protected:
     
    136141    void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier);
    137142    void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&);
     143    void unableToImplementPolicyWithError(WebKit::WebFrame*, const WebKit::WebURLError&);
     144    void didAddMessageToConsole(const WebKit::WebConsoleMessage&, const WebKit::WebString& sourceName, unsigned sourceLine);
     145    void runModalAlertDialog(WebKit::WebFrame*, const WebKit::WebString&);
     146    bool runModalConfirmDialog(WebKit::WebFrame*, const WebKit::WebString&);
     147    bool runModalPromptDialog(WebKit::WebFrame*, const WebKit::WebString& message, const WebKit::WebString& defaultValue, WebKit::WebString* actualValue);
     148    bool runModalBeforeUnloadDialog(WebKit::WebFrame*, const WebKit::WebString&);
    138149
    139150private:
     
    145156    WebKit::WebRect m_paintRect;
    146157    std::map<unsigned, std::string> m_resourceIdentifierMap;
     158
     159    bool m_logConsoleOutput;
    147160};
    148161
     
    392405        Base::didFailResourceLoad(frame, identifier, error);
    393406    }
     407    virtual void unableToImplementPolicyWithError(WebKit::WebFrame* frame, const WebKit::WebURLError& error)
     408    {
     409        WebTestProxyBase::unableToImplementPolicyWithError(frame, error);
     410        Base::unableToImplementPolicyWithError(frame, error);
     411    }
     412    virtual void didAddMessageToConsole(const WebKit::WebConsoleMessage& message, const WebKit::WebString& sourceName, unsigned sourceLine)
     413    {
     414        WebTestProxyBase::didAddMessageToConsole(message, sourceName, sourceLine);
     415        Base::didAddMessageToConsole(message, sourceName, sourceLine);
     416    }
     417    virtual void runModalAlertDialog(WebKit::WebFrame* frame, const WebKit::WebString& message)
     418    {
     419        WebTestProxyBase::runModalAlertDialog(frame, message);
     420        Base::runModalAlertDialog(frame, message);
     421    }
     422    virtual bool runModalConfirmDialog(WebKit::WebFrame* frame, const WebKit::WebString& message)
     423    {
     424        WebTestProxyBase::runModalConfirmDialog(frame, message);
     425        return Base::runModalConfirmDialog(frame, message);
     426    }
     427    virtual bool runModalPromptDialog(WebKit::WebFrame* frame, const WebKit::WebString& message, const WebKit::WebString& defaultValue, WebKit::WebString* actualValue)
     428    {
     429        WebTestProxyBase::runModalPromptDialog(frame, message, defaultValue, actualValue);
     430        return Base::runModalPromptDialog(frame, message, defaultValue, actualValue);
     431    }
     432    virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame, const WebKit::WebString& message)
     433    {
     434        WebTestProxyBase::runModalBeforeUnloadDialog(frame, message);
     435        return Base::runModalBeforeUnloadDialog(frame, message);
     436    }
    394437};
    395438
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp

    r140565 r140668  
    3737#include "WebAccessibilityObject.h"
    3838#include "WebCachedURLRequest.h"
     39#include "WebConsoleMessage.h"
    3940#include "WebElement.h"
    4041#include "WebEventSender.h"
     
    5051#include "WebView.h"
    5152#include <public/WebCString.h>
     53#include <public/WebURLError.h>
    5254#include <public/WebURLRequest.h>
    5355#include <public/WebURLResponse.h>
     
    187189}
    188190
     191// Used to write a platform neutral file:/// URL by only taking the filename
     192// (e.g., converts "file:///tmp/foo.txt" to just "foo.txt").
     193string urlSuitableForTestResult(const string& url)
     194{
     195    if (url.empty() || string::npos == url.find("file://"))
     196        return url;
     197
     198    size_t pos = url.rfind('/');
     199    if (pos == string::npos) {
     200#if OS(WINDOWS)
     201        pos = url.rfind('\\');
     202        if (pos == string::npos)
     203            pos = 0;
     204#else
     205        pos = 0;
     206#endif
     207    }
     208    string filename = url.substr(pos + 1);
     209    if (filename.empty())
     210        return "file:"; // A WebKit test has this in its expected output.
     211    return filename;
     212}
     213
    189214}
    190215
     
    194219    , m_spellcheck(new SpellCheckClient)
    195220{
     221    reset();
    196222}
    197223
     
    216242    m_paintRect = WebRect();
    217243    m_resourceIdentifierMap.clear();
     244    m_logConsoleOutput = true;
    218245}
    219246
     
    231258{
    232259    return m_paintRect;
     260}
     261
     262void WebTestProxyBase::setLogConsoleOutput(bool enabled)
     263{
     264    m_logConsoleOutput = enabled;
    233265}
    234266
     
    792824}
    793825
    794 }
     826void WebTestProxyBase::unableToImplementPolicyWithError(WebKit::WebFrame* frame, const WebKit::WebURLError& error)
     827{
     828    char errorBuffer[40];
     829    snprintf(errorBuffer, sizeof(errorBuffer), "%d", error.reason);
     830    m_delegate->printMessage(string("Policy delegate: unable to implement policy with error domain '") + error.domain.utf8().data() +
     831        "', error code " +  errorBuffer +
     832        ", in frame '" + frame->uniqueName().utf8().data() + "'\n");
     833}
     834
     835void WebTestProxyBase::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine)
     836{
     837    // This matches win DumpRenderTree's UIDelegate.cpp.
     838    if (!m_logConsoleOutput)
     839        return;
     840    m_delegate->printMessage(string("CONSOLE MESSAGE: "));
     841    if (sourceLine) {
     842        char buffer[40];
     843        snprintf(buffer, sizeof(buffer), "line %d: ", sourceLine);
     844        m_delegate->printMessage(buffer);
     845    }
     846    if (!message.text.isEmpty()) {
     847        string newMessage;
     848        newMessage = message.text.utf8();
     849        size_t fileProtocol = newMessage.find("file://");
     850        if (fileProtocol != string::npos) {
     851            newMessage = newMessage.substr(0, fileProtocol)
     852                + urlSuitableForTestResult(newMessage.substr(fileProtocol));
     853        }
     854        m_delegate->printMessage(newMessage);
     855    }
     856    m_delegate->printMessage(string("\n"));
     857}
     858
     859void WebTestProxyBase::runModalAlertDialog(WebFrame*, const WebString& message)
     860{
     861    m_delegate->printMessage(string("ALERT: ") + message.utf8().data() + "\n");
     862}
     863
     864bool WebTestProxyBase::runModalConfirmDialog(WebFrame*, const WebString& message)
     865{
     866    m_delegate->printMessage(string("CONFIRM: ") + message.utf8().data() + "\n");
     867    return true;
     868}
     869
     870bool WebTestProxyBase::runModalPromptDialog(WebFrame* frame, const WebString& message, const WebString& defaultValue, WebString*)
     871{
     872    m_delegate->printMessage(string("PROMPT: ") + message.utf8().data() + ", default text: " + defaultValue.utf8().data() + "\n");
     873    return true;
     874}
     875
     876bool WebTestProxyBase::runModalBeforeUnloadDialog(WebFrame*, const WebString& message)
     877{
     878    m_delegate->printMessage(string("CONFIRM NAVIGATION: ") + message.utf8().data() + "\n");
     879    return true;
     880}
     881
     882}
  • trunk/Tools/DumpRenderTree/chromium/TestShell.cpp

    r140653 r140668  
    222222        m_devTools = createNewWindow(url, 0, m_devToolsTestInterfaces.get());
    223223        m_devTools->webView()->settings()->setMemoryInfoEnabled(true);
    224         m_devTools->setLogConsoleOutput(false);
     224        m_devTools->proxy()->setLogConsoleOutput(false);
    225225        m_devToolsTestInterfaces->setDelegate(m_devTools);
    226226        m_devToolsTestInterfaces->setWebView(m_devTools->webView());
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r140565 r140668  
    105105static int nextPageID = 1;
    106106
    107 // Used to write a platform neutral file:/// URL by only taking the filename
    108 // (e.g., converts "file:///tmp/foo.txt" to just "foo.txt").
    109 static string urlSuitableForTestResult(const string& url)
    110 {
    111     if (url.empty() || string::npos == url.find("file://"))
    112         return url;
    113 
    114     size_t pos = url.rfind('/');
    115     if (pos == string::npos) {
    116 #if OS(WINDOWS)
    117         pos = url.rfind('\\');
    118         if (pos == string::npos)
    119             pos = 0;
    120 #else
    121         pos = 0;
    122 #endif
    123     }
    124     string filename = url.substr(pos + 1);
    125     if (filename.empty())
    126         return "file:"; // A WebKit test has this in its expected output.
    127     return filename;
    128 }
    129 
    130107// Get a debugging string from a WebNavigationType.
    131108static const char* webNavigationTypeToString(WebNavigationType type)
     
    224201void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine)
    225202{
    226     // This matches win DumpRenderTree's UIDelegate.cpp.
    227     if (!m_logConsoleOutput)
    228         return;
    229     string newMessage;
    230     if (!message.text.isEmpty()) {
    231         newMessage = message.text.utf8();
    232         size_t fileProtocol = newMessage.find("file://");
    233         if (fileProtocol != string::npos) {
    234             newMessage = newMessage.substr(0, fileProtocol)
    235                 + urlSuitableForTestResult(newMessage.substr(fileProtocol));
    236         }
    237     }
    238     printf("CONSOLE MESSAGE: ");
    239     if (sourceLine)
    240         printf("line %d: ", sourceLine);
    241     printf("%s\n", newMessage.data());
    242203}
    243204
     
    318279void WebViewHost::runModalAlertDialog(WebFrame*, const WebString& message)
    319280{
    320     printf("ALERT: %s\n", message.utf8().data());
    321     fflush(stdout);
    322281}
    323282
    324283bool WebViewHost::runModalConfirmDialog(WebFrame*, const WebString& message)
    325284{
    326     printf("CONFIRM: %s\n", message.utf8().data());
    327285    return true;
    328286}
     
    331289                                       const WebString& defaultValue, WebString*)
    332290{
    333     printf("PROMPT: %s, default text: %s\n", message.utf8().data(), defaultValue.utf8().data());
    334291    return true;
    335292}
     
    337294bool WebViewHost::runModalBeforeUnloadDialog(WebFrame*, const WebString& message)
    338295{
    339     printf("CONFIRM NAVIGATION: %s\n", message.utf8().data());
    340296    return !testRunner()->shouldStayOnPageAfterHandlingBeforeUnload();
    341297}
     
    724680void WebViewHost::unableToImplementPolicyWithError(WebFrame* frame, const WebURLError& error)
    725681{
    726     printf("Policy delegate: unable to implement policy with error domain '%s', "
    727            "error code %d, in frame '%s'\n",
    728             error.domain.utf8().data(), error.reason, frame->uniqueName().utf8().data());
    729682}
    730683
     
    12081161    m_inModalLoop = false;
    12091162    m_smartInsertDeleteEnabled = true;
    1210     m_logConsoleOutput = true;
    12111163#if OS(WINDOWS)
    12121164    m_selectTrailingWhitespaceEnabled = true;
     
    12661218{
    12671219    setWindowRect(rect);
    1268 }
    1269 
    1270 void WebViewHost::setLogConsoleOutput(bool enabled)
    1271 {
    1272     m_logConsoleOutput = enabled;
    12731220}
    12741221
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.h

    r140561 r140668  
    8787    void setProxy(WebTestRunner::WebTestProxyBase*);
    8888    void reset();
    89     void setLogConsoleOutput(bool);
    9089    void waitForPolicyDelegate();
    9190    void setCustomPolicyDelegate(bool, bool);
     
    385384    bool m_selectTrailingWhitespaceEnabled;
    386385
    387     // true if whatever is sent to the console should be logged to stdout.
    388     bool m_logConsoleOutput;
    389 
    390386    // Edit command associated to the current keyboard event.
    391387    std::string m_editCommandName;
Note: See TracChangeset for help on using the changeset viewer.