Title: [140668] trunk/Tools
Revision
140668
Author
[email protected]
Date
2013-01-24 02:12:56 -0800 (Thu, 24 Jan 2013)

Log Message

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

Patch by Dan Carney <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (140667 => 140668)


--- trunk/Tools/ChangeLog	2013-01-24 10:11:51 UTC (rev 140667)
+++ trunk/Tools/ChangeLog	2013-01-24 10:12:56 UTC (rev 140668)
@@ -1,3 +1,43 @@
+2013-01-24  Dan Carney  <[email protected]>
+
+        [chromium] move most WebViewHost printf calls to WebTestProxy
+        https://bugs.webkit.org/show_bug.cgi?id=107553
+
+        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):
+
 2013-01-23  Mark Pilgrim  <[email protected]>
 
         [Chromium] Give webkit_support a chance to reset state between layout test runs

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h (140667 => 140668)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2013-01-24 10:11:51 UTC (rev 140667)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2013-01-24 10:12:56 UTC (rev 140668)
@@ -41,6 +41,8 @@
 #include <map>
 #include <string>
 
+#define TEST_RUNNER_MOVED_PRINTING 1
+
 namespace WebKit {
 class WebAccessibilityObject;
 class WebCachedURLRequest;
@@ -59,6 +61,7 @@
 class WebURLRequest;
 class WebURLResponse;
 class WebView;
+struct WebConsoleMessage;
 struct WebPoint;
 struct WebSize;
 struct WebURLError;
@@ -84,6 +87,8 @@
     void setPaintRect(const WebKit::WebRect&);
     WebKit::WebRect paintRect() const;
 
+    void setLogConsoleOutput(bool enabled);
+
 protected:
     WebTestProxyBase();
     ~WebTestProxyBase();
@@ -135,6 +140,12 @@
     void didReceiveResponse(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&);
     void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier);
     void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&);
+    void unableToImplementPolicyWithError(WebKit::WebFrame*, const WebKit::WebURLError&);
+    void didAddMessageToConsole(const WebKit::WebConsoleMessage&, const WebKit::WebString& sourceName, unsigned sourceLine);
+    void runModalAlertDialog(WebKit::WebFrame*, const WebKit::WebString&);
+    bool runModalConfirmDialog(WebKit::WebFrame*, const WebKit::WebString&);
+    bool runModalPromptDialog(WebKit::WebFrame*, const WebKit::WebString& message, const WebKit::WebString& defaultValue, WebKit::WebString* actualValue);
+    bool runModalBeforeUnloadDialog(WebKit::WebFrame*, const WebKit::WebString&);
 
 private:
     WebTestInterfaces* m_testInterfaces;
@@ -144,6 +155,8 @@
 
     WebKit::WebRect m_paintRect;
     std::map<unsigned, std::string> m_resourceIdentifierMap;
+
+    bool m_logConsoleOutput;
 };
 
 // Use this template to inject methods into your WebViewClient/WebFrameClient
@@ -391,6 +404,36 @@
         WebTestProxyBase::didFailResourceLoad(frame, identifier, error);
         Base::didFailResourceLoad(frame, identifier, error);
     }
+    virtual void unableToImplementPolicyWithError(WebKit::WebFrame* frame, const WebKit::WebURLError& error)
+    {
+        WebTestProxyBase::unableToImplementPolicyWithError(frame, error);
+        Base::unableToImplementPolicyWithError(frame, error);
+    }
+    virtual void didAddMessageToConsole(const WebKit::WebConsoleMessage& message, const WebKit::WebString& sourceName, unsigned sourceLine)
+    {
+        WebTestProxyBase::didAddMessageToConsole(message, sourceName, sourceLine);
+        Base::didAddMessageToConsole(message, sourceName, sourceLine);
+    }
+    virtual void runModalAlertDialog(WebKit::WebFrame* frame, const WebKit::WebString& message)
+    {
+        WebTestProxyBase::runModalAlertDialog(frame, message);
+        Base::runModalAlertDialog(frame, message);
+    }
+    virtual bool runModalConfirmDialog(WebKit::WebFrame* frame, const WebKit::WebString& message)
+    {
+        WebTestProxyBase::runModalConfirmDialog(frame, message);
+        return Base::runModalConfirmDialog(frame, message);
+    }
+    virtual bool runModalPromptDialog(WebKit::WebFrame* frame, const WebKit::WebString& message, const WebKit::WebString& defaultValue, WebKit::WebString* actualValue)
+    {
+        WebTestProxyBase::runModalPromptDialog(frame, message, defaultValue, actualValue);
+        return Base::runModalPromptDialog(frame, message, defaultValue, actualValue);
+    }
+    virtual bool runModalBeforeUnloadDialog(WebKit::WebFrame* frame, const WebKit::WebString& message)
+    {
+        WebTestProxyBase::runModalBeforeUnloadDialog(frame, message);
+        return Base::runModalBeforeUnloadDialog(frame, message);
+    }
 };
 
 }

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp (140667 => 140668)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2013-01-24 10:11:51 UTC (rev 140667)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2013-01-24 10:12:56 UTC (rev 140668)
@@ -36,6 +36,7 @@
 #include "WebAccessibilityNotification.h"
 #include "WebAccessibilityObject.h"
 #include "WebCachedURLRequest.h"
+#include "WebConsoleMessage.h"
 #include "WebElement.h"
 #include "WebEventSender.h"
 #include "WebFrame.h"
@@ -49,6 +50,7 @@
 #include "WebTestRunner.h"
 #include "WebView.h"
 #include <public/WebCString.h>
+#include <public/WebURLError.h>
 #include <public/WebURLRequest.h>
 #include <public/WebURLResponse.h>
 #include <wtf/StringExtras.h>
@@ -186,13 +188,37 @@
     request.setURL(WebURL());
 }
 
+// Used to write a platform neutral file:/// URL by only taking the filename
+// (e.g., converts "file:///tmp/foo.txt" to just "foo.txt").
+string urlSuitableForTestResult(const string& url)
+{
+    if (url.empty() || string::npos == url.find("file://"))
+        return url;
+
+    size_t pos = url.rfind('/');
+    if (pos == string::npos) {
+#if OS(WINDOWS)
+        pos = url.rfind('\\');
+        if (pos == string::npos)
+            pos = 0;
+#else
+        pos = 0;
+#endif
+    }
+    string filename = url.substr(pos + 1);
+    if (filename.empty())
+        return "file:"; // A WebKit test has this in its expected output.
+    return filename;
 }
 
+}
+
 WebTestProxyBase::WebTestProxyBase()
     : m_testInterfaces(0)
     , m_delegate(0)
     , m_spellcheck(new SpellCheckClient)
 {
+    reset();
 }
 
 WebTestProxyBase::~WebTestProxyBase()
@@ -215,6 +241,7 @@
 {
     m_paintRect = WebRect();
     m_resourceIdentifierMap.clear();
+    m_logConsoleOutput = true;
 }
 
 WebSpellCheckClient* WebTestProxyBase::spellCheckClient() const
@@ -232,6 +259,11 @@
     return m_paintRect;
 }
 
+void WebTestProxyBase::setLogConsoleOutput(bool enabled)
+{
+    m_logConsoleOutput = enabled;
+}
+
 void WebTestProxyBase::didInvalidateRect(const WebRect& rect)
 {
     // m_paintRect = m_paintRect U rect
@@ -791,4 +823,60 @@
     m_resourceIdentifierMap.erase(identifier);
 }
 
+void WebTestProxyBase::unableToImplementPolicyWithError(WebKit::WebFrame* frame, const WebKit::WebURLError& error)
+{
+    char errorBuffer[40];
+    snprintf(errorBuffer, sizeof(errorBuffer), "%d", error.reason);
+    m_delegate->printMessage(string("Policy delegate: unable to implement policy with error domain '") + error.domain.utf8().data() +
+        "', error code " +  errorBuffer +
+        ", in frame '" + frame->uniqueName().utf8().data() + "'\n");
 }
+
+void WebTestProxyBase::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine)
+{
+    // This matches win DumpRenderTree's UIDelegate.cpp.
+    if (!m_logConsoleOutput)
+        return;
+    m_delegate->printMessage(string("CONSOLE MESSAGE: "));
+    if (sourceLine) {
+        char buffer[40];
+        snprintf(buffer, sizeof(buffer), "line %d: ", sourceLine);
+        m_delegate->printMessage(buffer);
+    }
+    if (!message.text.isEmpty()) {
+        string newMessage;
+        newMessage = message.text.utf8();
+        size_t fileProtocol = newMessage.find("file://");
+        if (fileProtocol != string::npos) {
+            newMessage = newMessage.substr(0, fileProtocol)
+                + urlSuitableForTestResult(newMessage.substr(fileProtocol));
+        }
+        m_delegate->printMessage(newMessage);
+    }
+    m_delegate->printMessage(string("\n"));
+}
+
+void WebTestProxyBase::runModalAlertDialog(WebFrame*, const WebString& message)
+{
+    m_delegate->printMessage(string("ALERT: ") + message.utf8().data() + "\n");
+}
+
+bool WebTestProxyBase::runModalConfirmDialog(WebFrame*, const WebString& message)
+{
+    m_delegate->printMessage(string("CONFIRM: ") + message.utf8().data() + "\n");
+    return true;
+}
+
+bool WebTestProxyBase::runModalPromptDialog(WebFrame* frame, const WebString& message, const WebString& defaultValue, WebString*)
+{
+    m_delegate->printMessage(string("PROMPT: ") + message.utf8().data() + ", default text: " + defaultValue.utf8().data() + "\n");
+    return true;
+}
+
+bool WebTestProxyBase::runModalBeforeUnloadDialog(WebFrame*, const WebString& message)
+{
+    m_delegate->printMessage(string("CONFIRM NAVIGATION: ") + message.utf8().data() + "\n");
+    return true;
+}
+
+}

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (140667 => 140668)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2013-01-24 10:11:51 UTC (rev 140667)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2013-01-24 10:12:56 UTC (rev 140668)
@@ -221,7 +221,7 @@
         }
         m_devTools = createNewWindow(url, 0, m_devToolsTestInterfaces.get());
         m_devTools->webView()->settings()->setMemoryInfoEnabled(true);
-        m_devTools->setLogConsoleOutput(false);
+        m_devTools->proxy()->setLogConsoleOutput(false);
         m_devToolsTestInterfaces->setDelegate(m_devTools);
         m_devToolsTestInterfaces->setWebView(m_devTools->webView());
         ASSERT(m_devTools);

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (140667 => 140668)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2013-01-24 10:11:51 UTC (rev 140667)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2013-01-24 10:12:56 UTC (rev 140668)
@@ -104,29 +104,6 @@
 
 static int nextPageID = 1;
 
-// Used to write a platform neutral file:/// URL by only taking the filename
-// (e.g., converts "file:///tmp/foo.txt" to just "foo.txt").
-static string urlSuitableForTestResult(const string& url)
-{
-    if (url.empty() || string::npos == url.find("file://"))
-        return url;
-
-    size_t pos = url.rfind('/');
-    if (pos == string::npos) {
-#if OS(WINDOWS)
-        pos = url.rfind('\\');
-        if (pos == string::npos)
-            pos = 0;
-#else
-        pos = 0;
-#endif
-    }
-    string filename = url.substr(pos + 1);
-    if (filename.empty())
-        return "file:"; // A WebKit test has this in its expected output.
-    return filename;
-}
-
 // Get a debugging string from a WebNavigationType.
 static const char* webNavigationTypeToString(WebNavigationType type)
 {
@@ -223,22 +200,6 @@
 
 void WebViewHost::didAddMessageToConsole(const WebConsoleMessage& message, const WebString& sourceName, unsigned sourceLine)
 {
-    // This matches win DumpRenderTree's UIDelegate.cpp.
-    if (!m_logConsoleOutput)
-        return;
-    string newMessage;
-    if (!message.text.isEmpty()) {
-        newMessage = message.text.utf8();
-        size_t fileProtocol = newMessage.find("file://");
-        if (fileProtocol != string::npos) {
-            newMessage = newMessage.substr(0, fileProtocol)
-                + urlSuitableForTestResult(newMessage.substr(fileProtocol));
-        }
-    }
-    printf("CONSOLE MESSAGE: ");
-    if (sourceLine)
-        printf("line %d: ", sourceLine);
-    printf("%s\n", newMessage.data());
 }
 
 void WebViewHost::didStartLoading()
@@ -317,26 +278,21 @@
 
 void WebViewHost::runModalAlertDialog(WebFrame*, const WebString& message)
 {
-    printf("ALERT: %s\n", message.utf8().data());
-    fflush(stdout);
 }
 
 bool WebViewHost::runModalConfirmDialog(WebFrame*, const WebString& message)
 {
-    printf("CONFIRM: %s\n", message.utf8().data());
     return true;
 }
 
 bool WebViewHost::runModalPromptDialog(WebFrame* frame, const WebString& message,
                                        const WebString& defaultValue, WebString*)
 {
-    printf("PROMPT: %s, default text: %s\n", message.utf8().data(), defaultValue.utf8().data());
     return true;
 }
 
 bool WebViewHost::runModalBeforeUnloadDialog(WebFrame*, const WebString& message)
 {
-    printf("CONFIRM NAVIGATION: %s\n", message.utf8().data());
     return !testRunner()->shouldStayOnPageAfterHandlingBeforeUnload();
 }
 
@@ -723,9 +679,6 @@
 
 void WebViewHost::unableToImplementPolicyWithError(WebFrame* frame, const WebURLError& error)
 {
-    printf("Policy delegate: unable to implement policy with error domain '%s', "
-           "error code %d, in frame '%s'\n",
-            error.domain.utf8().data(), error.reason, frame->uniqueName().utf8().data());
 }
 
 void WebViewHost::didCreateDataSource(WebFrame*, WebDataSource* ds)
@@ -1207,7 +1160,6 @@
     m_hasWindow = false;
     m_inModalLoop = false;
     m_smartInsertDeleteEnabled = true;
-    m_logConsoleOutput = true;
 #if OS(WINDOWS)
     m_selectTrailingWhitespaceEnabled = true;
 #else
@@ -1267,11 +1219,6 @@
     setWindowRect(rect);
 }
 
-void WebViewHost::setLogConsoleOutput(bool enabled)
-{
-    m_logConsoleOutput = enabled;
-}
-
 void WebViewHost::setCustomPolicyDelegate(bool isCustom, bool isPermissive)
 {
     m_policyDelegateEnabled = isCustom;

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (140667 => 140668)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2013-01-24 10:11:51 UTC (rev 140667)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2013-01-24 10:12:56 UTC (rev 140668)
@@ -86,7 +86,6 @@
     WebTestRunner::WebTestProxyBase* proxy() const;
     void setProxy(WebTestRunner::WebTestProxyBase*);
     void reset();
-    void setLogConsoleOutput(bool);
     void waitForPolicyDelegate();
     void setCustomPolicyDelegate(bool, bool);
     WebKit::WebFrame* topLoadingFrame() { return m_topLoadingFrame; }
@@ -384,9 +383,6 @@
     // true if we want to enable selection of trailing whitespaces
     bool m_selectTrailingWhitespaceEnabled;
 
-    // true if whatever is sent to the console should be logged to stdout.
-    bool m_logConsoleOutput;
-
     // Edit command associated to the current keyboard event.
     std::string m_editCommandName;
     std::string m_editCommandValue;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to