Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1532)

Unified Diff: content/shell/shell_render_process_observer.cc

Issue 11245004: [content shell] link against the TestRunner library (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/shell_render_process_observer.h ('k') | content/shell/webkit_test_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/shell_render_process_observer.cc
diff --git a/content/shell/shell_render_process_observer.cc b/content/shell/shell_render_process_observer.cc
index 25f4f95536620ba891c1011bfa733a820c639b81..250c91165d73cf6b428154c3cb7480b00547bc68 100644
--- a/content/shell/shell_render_process_observer.cc
+++ b/content/shell/shell_render_process_observer.cc
@@ -5,19 +5,63 @@
#include "content/shell/shell_render_process_observer.h"
#include "base/command_line.h"
+#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_thread.h"
+#include "content/shell/shell_messages.h"
#include "content/shell/shell_switches.h"
#include "content/shell/webkit_test_runner_bindings.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/support/gc_extension.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h"
+#include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestInterfaces.h"
+
+using WebKit::WebFrame;
+using WebKit::WebTestingSupport;
+using WebTestRunner::WebTestDelegate;
+using WebTestRunner::WebTestInterfaces;
namespace content {
-ShellRenderProcessObserver::ShellRenderProcessObserver() {
+namespace {
+ShellRenderProcessObserver* g_instance = NULL;
+}
+
+// static
+ShellRenderProcessObserver* ShellRenderProcessObserver::GetInstance() {
+ return g_instance;
+}
+
+ShellRenderProcessObserver::ShellRenderProcessObserver()
+ : test_delegate_(NULL) {
+ CHECK(!g_instance);
+ g_instance = this;
RenderThread::Get()->AddObserver(this);
}
ShellRenderProcessObserver::~ShellRenderProcessObserver() {
+ CHECK(g_instance == this);
+ g_instance = NULL;
+}
+
+void ShellRenderProcessObserver::SetMainWindow(
+ RenderView* view,
+ WebTestDelegate* delegate) {
+ if (view == NULL) {
+ if (delegate == test_delegate_) {
+ test_interfaces_->setDelegate(NULL);
+ test_interfaces_->setWebView(NULL);
+ test_delegate_ = NULL;
+ }
+ } else {
+ test_interfaces_->setDelegate(delegate);
+ test_interfaces_->setWebView(view->GetWebView());
+ test_delegate_ = delegate;
+ }
+}
+
+void ShellRenderProcessObserver::BindTestRunnersToWindow(WebFrame* frame) {
+ WebTestingSupport::injectInternalsObject(frame);
+ test_interfaces_->bindTo(frame);
}
void ShellRenderProcessObserver::WebKitInitialized() {
@@ -31,6 +75,24 @@ void ShellRenderProcessObserver::WebKitInitialized() {
// We always expose GC to layout tests.
webkit_glue::SetJavaScriptFlags(" --expose-gc");
RenderThread::Get()->RegisterExtension(extensions_v8::GCExtension::Get());
+
+ test_interfaces_.reset(new WebTestInterfaces);
+}
+
+bool ShellRenderProcessObserver::OnControlMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message)
+ IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ return handled;
+}
+
+void ShellRenderProcessObserver::OnResetAll() {
+ test_interfaces_->resetAll();
+ // We don't reset the WebTestingSupport objects, as we don't reuse WebViews.
}
} // namespace content
« no previous file with comments | « content/shell/shell_render_process_observer.h ('k') | content/shell/webkit_test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698