summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 14:11:45 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-10 14:11:45 +0000
commit8dafad32e63d4f8657aa88f0b17254d8a91727d6 (patch)
tree507e0efda9a158d7c4cdec63a426dd3329cebe8e /content
parent2393323faddbbb25933c7a5942cbde786075e536 (diff)
downloadchromium_src-8dafad32e63d4f8657aa88f0b17254d8a91727d6.zip
chromium_src-8dafad32e63d4f8657aa88f0b17254d8a91727d6.tar.gz
chromium_src-8dafad32e63d4f8657aa88f0b17254d8a91727d6.tar.bz2
[content shell] remove WebKitTestRunnerHost.
Instead of having an observer per WebContents, only observe the main window. In a previous patch, all IPC messages were already routed to this one main window. Also, rename webkit_test_runner_host.* to webkit_test_controller.* BUG=111316 TEST=nothing breaks R=marja@chromium.org Review URL: https://chromiumcodereview.appspot.com/11494004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/content_shell.gypi4
-rw-r--r--content/shell/shell.cc2
-rw-r--r--content/shell/shell_browser_main.cc2
-rw-r--r--content/shell/shell_content_browser_client.cc9
-rw-r--r--content/shell/shell_content_browser_client.h2
-rw-r--r--content/shell/shell_javascript_dialog_creator.cc2
-rw-r--r--content/shell/webkit_test_controller.cc (renamed from content/shell/webkit_test_runner_host.cc)116
-rw-r--r--content/shell/webkit_test_controller.h (renamed from content/shell/webkit_test_runner_host.h)58
-rw-r--r--content/test/layout_browsertest.cc2
9 files changed, 59 insertions, 138 deletions
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index bdd93bc..5a905d2 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -117,6 +117,8 @@
'shell/shell_web_contents_view_delegate_mac.mm',
'shell/shell_web_contents_view_delegate_win.cc',
'shell/shell_web_contents_view_delegate.h',
+ 'shell/webkit_test_controller.cc',
+ 'shell/webkit_test_controller.h',
'shell/webkit_test_platform_support.h',
'shell/webkit_test_platform_support_android.cc',
'shell/webkit_test_platform_support_linux.cc',
@@ -126,8 +128,6 @@
'shell/webkit_test_runner.h',
'shell/webkit_test_runner_bindings.cc',
'shell/webkit_test_runner_bindings.h',
- 'shell/webkit_test_runner_host.cc',
- 'shell/webkit_test_runner_host.h',
],
'msvs_settings': {
'VCLinkerTool': {
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index fd27d15..db6b856 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -26,7 +26,7 @@
#include "content/shell/shell_javascript_dialog_creator.h"
#include "content/shell/shell_messages.h"
#include "content/shell/shell_switches.h"
-#include "content/shell/webkit_test_runner_host.h"
+#include "content/shell/webkit_test_controller.h"
#include "ui/gfx/size.h"
// Content area size for newly created windows.
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index bfa2e0e..283617c 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -17,7 +17,7 @@
#include "base/utf_string_conversions.h"
#include "content/public/browser/browser_main_runner.h"
#include "content/shell/shell_switches.h"
-#include "content/shell/webkit_test_runner_host.h"
+#include "content/shell/webkit_test_controller.h"
#include "net/base/net_util.h"
#include "webkit/support/webkit_support.h"
diff --git a/content/shell/shell_content_browser_client.cc b/content/shell/shell_content_browser_client.cc
index 4019199..ee4fd62 100644
--- a/content/shell/shell_content_browser_client.cc
+++ b/content/shell/shell_content_browser_client.cc
@@ -18,7 +18,7 @@
#include "content/shell/shell_resource_dispatcher_host_delegate.h"
#include "content/shell/shell_switches.h"
#include "content/shell/shell_web_contents_view_delegate_creator.h"
-#include "content/shell/webkit_test_runner_host.h"
+#include "content/shell/webkit_test_controller.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/webpreferences.h"
@@ -79,13 +79,6 @@ void ShellContentBrowserClient::RenderProcessHostCreated(
host->Send(new ShellViewMsg_SetWebKitSourceDir(webkit_source_dir_));
}
-void ShellContentBrowserClient::RenderViewHostCreated(
- RenderViewHost* render_view_host) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
- return;
- new WebKitTestRunnerHost(render_view_host);
-}
-
void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
CommandLine* command_line, int child_process_id) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
diff --git a/content/shell/shell_content_browser_client.h b/content/shell/shell_content_browser_client.h
index 06f6516..f5652a9 100644
--- a/content/shell/shell_content_browser_client.h
+++ b/content/shell/shell_content_browser_client.h
@@ -27,8 +27,6 @@ class ShellContentBrowserClient : public ContentBrowserClient {
virtual BrowserMainParts* CreateBrowserMainParts(
const MainFunctionParams& parameters) OVERRIDE;
virtual void RenderProcessHostCreated(RenderProcessHost* host) OVERRIDE;
- virtual void RenderViewHostCreated(
- RenderViewHost* render_view_host) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) OVERRIDE;
virtual void OverrideWebkitPrefs(RenderViewHost* render_view_host,
diff --git a/content/shell/shell_javascript_dialog_creator.cc b/content/shell/shell_javascript_dialog_creator.cc
index 00342a4..6b97dc4 100644
--- a/content/shell/shell_javascript_dialog_creator.cc
+++ b/content/shell/shell_javascript_dialog_creator.cc
@@ -11,7 +11,7 @@
#include "content/public/browser/web_contents_view.h"
#include "content/shell/shell_javascript_dialog.h"
#include "content/shell/shell_switches.h"
-#include "content/shell/webkit_test_runner_host.h"
+#include "content/shell/webkit_test_controller.h"
#include "net/base/net_util.h"
namespace content {
diff --git a/content/shell/webkit_test_runner_host.cc b/content/shell/webkit_test_controller.cc
index 5eef32d..893ee31 100644
--- a/content/shell/webkit_test_runner_host.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/shell/webkit_test_runner_host.h"
+#include "content/shell/webkit_test_controller.h"
#include <iostream>
@@ -196,35 +196,6 @@ void WebKitTestController::RendererUnresponsive() {
printer_->AddErrorMessage("#PROCESS UNRESPONSIVE - renderer");
}
-void WebKitTestController::NotifyDone() {
- if (!wait_until_done_)
- return;
- watchdog_.Cancel();
- CaptureDump();
-}
-
-void WebKitTestController::WaitUntilDone() {
- if (wait_until_done_)
- return;
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTimeout)) {
- watchdog_.Reset(base::Bind(&WebKitTestController::TimeoutHandler,
- base::Unretained(this)));
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- watchdog_.callback(),
- base::TimeDelta::FromMilliseconds(kTestTimeoutMilliseconds));
- }
- wait_until_done_ = true;
-}
-
-void WebKitTestController::NotImplemented(
- const std::string& object_name,
- const std::string& property_name) {
- printer_->AddErrorMessage(
- std::string("FAIL: NOT IMPLEMENTED: ") +
- object_name + "." + property_name);
-}
-
bool WebKitTestController::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(WebKitTestController, message)
@@ -234,6 +205,16 @@ bool WebKitTestController::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences,
OnOverridePreferences)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_NotifyDone, OnNotifyDone)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_DumpAsText, OnDumpAsText)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_DumpChildFramesAsText,
+ OnDumpChildFramesAsText)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetPrinting, OnSetPrinting)
+ IPC_MESSAGE_HANDLER(
+ ShellViewHostMsg_SetShouldStayOnPageAfterHandlingBeforeUnload,
+ OnSetShouldStayOnPageAfterHandlingBeforeUnload)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_WaitUntilDone, OnWaitUntilDone)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_NotImplemented, OnNotImplemented)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -356,67 +337,50 @@ void WebKitTestController::OnOverridePreferences(
prefs_ = prefs;
}
-// WebKitTestRunnerHost -------------------------------------------------------
-
-WebKitTestRunnerHost::WebKitTestRunnerHost(
- RenderViewHost* render_view_host)
- : RenderViewHostObserver(render_view_host) {
-}
-
-WebKitTestRunnerHost::~WebKitTestRunnerHost() {
-}
-
-bool WebKitTestRunnerHost::OnMessageReceived(
- const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(WebKitTestRunnerHost, message)
- IPC_MESSAGE_HANDLER(ShellViewHostMsg_NotifyDone, OnNotifyDone)
- IPC_MESSAGE_HANDLER(ShellViewHostMsg_DumpAsText, OnDumpAsText)
- IPC_MESSAGE_HANDLER(ShellViewHostMsg_DumpChildFramesAsText,
- OnDumpChildFramesAsText)
- IPC_MESSAGE_HANDLER(ShellViewHostMsg_SetPrinting, OnSetPrinting)
- IPC_MESSAGE_HANDLER(
- ShellViewHostMsg_SetShouldStayOnPageAfterHandlingBeforeUnload,
- OnSetShouldStayOnPageAfterHandlingBeforeUnload)
- IPC_MESSAGE_HANDLER(ShellViewHostMsg_WaitUntilDone, OnWaitUntilDone)
- IPC_MESSAGE_HANDLER(ShellViewHostMsg_NotImplemented, OnNotImplemented)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- return handled;
-}
-
-void WebKitTestRunnerHost::OnNotifyDone() {
- WebKitTestController::Get()->NotifyDone();
+void WebKitTestController::OnNotifyDone() {
+ if (!wait_until_done_)
+ return;
+ watchdog_.Cancel();
+ CaptureDump();
}
-void WebKitTestRunnerHost::OnDumpAsText() {
- WebKitTestController::Get()->set_dump_as_text(true);
+void WebKitTestController::OnDumpAsText() {
+ dump_as_text_ = true;
}
-void WebKitTestRunnerHost::OnSetPrinting() {
- WebKitTestController::Get()->set_is_printing(true);
+void WebKitTestController::OnSetPrinting() {
+ is_printing_ = true;
}
-void WebKitTestRunnerHost::OnSetShouldStayOnPageAfterHandlingBeforeUnload(
+void WebKitTestController::OnSetShouldStayOnPageAfterHandlingBeforeUnload(
bool should_stay_on_page) {
- WebKitTestController* controller = WebKitTestController::Get();
- controller->set_should_stay_on_page_after_handling_before_unload(
- should_stay_on_page);
+ should_stay_on_page_after_handling_before_unload_ = should_stay_on_page;
}
-void WebKitTestRunnerHost::OnDumpChildFramesAsText() {
- WebKitTestController::Get()->set_dump_child_frames(true);
+void WebKitTestController::OnDumpChildFramesAsText() {
+ dump_child_frames_ = true;
}
-void WebKitTestRunnerHost::OnWaitUntilDone() {
- WebKitTestController::Get()->WaitUntilDone();
+void WebKitTestController::OnWaitUntilDone() {
+ if (wait_until_done_)
+ return;
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTimeout)) {
+ watchdog_.Reset(base::Bind(&WebKitTestController::TimeoutHandler,
+ base::Unretained(this)));
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ watchdog_.callback(),
+ base::TimeDelta::FromMilliseconds(kTestTimeoutMilliseconds));
+ }
+ wait_until_done_ = true;
}
-void WebKitTestRunnerHost::OnNotImplemented(
+void WebKitTestController::OnNotImplemented(
const std::string& object_name,
const std::string& property_name) {
- WebKitTestController::Get()->NotImplemented(object_name, property_name);
+ printer_->AddErrorMessage(
+ std::string("FAIL: NOT IMPLEMENTED: ") +
+ object_name + "." + property_name);
}
} // namespace content
diff --git a/content/shell/webkit_test_runner_host.h b/content/shell/webkit_test_controller.h
index 596a910..03de47b 100644
--- a/content/shell/webkit_test_runner_host.h
+++ b/content/shell/webkit_test_controller.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_SHELL_WEBKIT_TEST_RUNNER_HOST_H_
-#define CONTENT_SHELL_WEBKIT_TEST_RUNNER_HOST_H_
+#ifndef CONTENT_SHELL_WEBKIT_TEST_CONTROLLER_H_
+#define CONTENT_SHELL_WEBKIT_TEST_CONTROLLER_H_
#include <ostream>
#include <string>
@@ -86,29 +86,9 @@ class WebKitTestController : public base::NonThreadSafe,
printer_.reset(printer);
}
const ShellWebPreferences& web_preferences() const { return prefs_; }
-
- // Interface for WebKitTestRunnerHost.
- void NotifyDone();
- void WaitUntilDone();
- void NotImplemented(const std::string& object_name,
- const std::string& method_name);
-
bool should_stay_on_page_after_handling_before_unload() const {
return should_stay_on_page_after_handling_before_unload_;
}
- void set_should_stay_on_page_after_handling_before_unload(
- bool should_stay_on_page_after_handling_before_unload) {
- should_stay_on_page_after_handling_before_unload_ =
- should_stay_on_page_after_handling_before_unload;
- }
- bool dump_as_text() const { return dump_as_text_; }
- void set_dump_as_text(bool dump_as_text) { dump_as_text_ = dump_as_text; }
- bool dump_child_frames() const { return dump_child_frames_; }
- void set_dump_child_frames(bool dump_child_frames) {
- dump_child_frames_ = dump_child_frames;
- }
- bool is_printing() const { return is_printing_; }
- void set_is_printing(bool is_printing) { is_printing_ = is_printing; }
// WebContentsObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
@@ -129,6 +109,15 @@ class WebKitTestController : public base::NonThreadSafe,
void OnTextDump(const std::string& dump);
void OnPrintMessage(const std::string& message);
void OnOverridePreferences(const ShellWebPreferences& prefs);
+ void OnNotifyDone();
+ void OnDumpAsText();
+ void OnDumpChildFramesAsText();
+ void OnSetPrinting();
+ void OnSetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page);
+ void OnWaitUntilDone();
+
+ void OnNotImplemented(const std::string& object_name,
+ const std::string& method_name);
scoped_ptr<WebKitTestResultPrinter> printer_;
@@ -153,29 +142,6 @@ class WebKitTestController : public base::NonThreadSafe,
DISALLOW_COPY_AND_ASSIGN(WebKitTestController);
};
-class WebKitTestRunnerHost : public RenderViewHostObserver {
- public:
- explicit WebKitTestRunnerHost(RenderViewHost* render_view_host);
- virtual ~WebKitTestRunnerHost();
-
- // RenderViewHostObserver implementation.
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-
- private:
- // testRunner handlers.
- void OnNotifyDone();
- void OnDumpAsText();
- void OnDumpChildFramesAsText();
- void OnSetPrinting();
- void OnSetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page);
- void OnWaitUntilDone();
-
- void OnNotImplemented(const std::string& object_name,
- const std::string& method_name);
-
- DISALLOW_COPY_AND_ASSIGN(WebKitTestRunnerHost);
-};
-
} // namespace content
-#endif // CONTENT_SHELL_WEBKIT_TEST_RUNNER_HOST_H_
+#endif // CONTENT_SHELL_WEBKIT_TEST_CONTROLLER_H_
diff --git a/content/test/layout_browsertest.cc b/content/test/layout_browsertest.cc
index 3098a08..35f1c4d 100644
--- a/content/test/layout_browsertest.cc
+++ b/content/test/layout_browsertest.cc
@@ -21,7 +21,7 @@
#include "content/public/test/browser_test_utils.h"
#include "content/shell/shell.h"
#include "content/shell/shell_switches.h"
-#include "content/shell/webkit_test_runner_host.h"
+#include "content/shell/webkit_test_controller.h"
#include "content/test/content_browser_test_utils.h"
#include "content/test/layout_test_http_server.h"
#include "net/base/net_util.h"