| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/renderer/layout_test/layout_test_render_process_observer
.h" | 5 #include "content/shell/renderer/layout_test/layout_test_render_process_observer
.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "components/test_runner/event_sender.h" | |
| 9 #include "components/test_runner/test_interfaces.h" | 8 #include "components/test_runner/test_interfaces.h" |
| 10 #include "components/test_runner/web_test_interfaces.h" | 9 #include "components/test_runner/web_test_interfaces.h" |
| 11 #include "content/common/input/input_event_utils.h" | 10 #include "content/common/input/input_event_utils.h" |
| 12 #include "content/public/common/content_client.h" | 11 #include "content/public/common/content_client.h" |
| 13 #include "content/public/renderer/render_thread.h" | 12 #include "content/public/renderer/render_thread.h" |
| 14 #include "content/public/renderer/render_view.h" | |
| 15 #include "content/public/test/layouttest_support.h" | 13 #include "content/public/test/layouttest_support.h" |
| 16 #include "content/shell/common/layout_test/layout_test_switches.h" | 14 #include "content/shell/common/layout_test/layout_test_switches.h" |
| 17 #include "content/shell/common/shell_messages.h" | 15 #include "content/shell/common/shell_messages.h" |
| 18 #include "content/shell/renderer/layout_test/blink_test_runner.h" | 16 #include "content/shell/renderer/layout_test/blink_test_runner.h" |
| 19 #include "third_party/WebKit/public/web/WebKit.h" | 17 #include "third_party/WebKit/public/web/WebKit.h" |
| 20 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 18 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 21 #include "third_party/WebKit/public/web/WebView.h" | |
| 22 #include "v8/include/v8.h" | 19 #include "v8/include/v8.h" |
| 23 | 20 |
| 24 using blink::WebFrame; | 21 using blink::WebFrame; |
| 25 using blink::WebRuntimeFeatures; | 22 using blink::WebRuntimeFeatures; |
| 26 | 23 |
| 27 namespace content { | 24 namespace content { |
| 28 | 25 |
| 29 namespace { | 26 namespace { |
| 30 LayoutTestRenderProcessObserver* g_instance = NULL; | 27 LayoutTestRenderProcessObserver* g_instance = NULL; |
| 31 } | 28 } |
| 32 | 29 |
| 33 // static | 30 // static |
| 34 LayoutTestRenderProcessObserver* | 31 LayoutTestRenderProcessObserver* |
| 35 LayoutTestRenderProcessObserver::GetInstance() { | 32 LayoutTestRenderProcessObserver::GetInstance() { |
| 36 return g_instance; | 33 return g_instance; |
| 37 } | 34 } |
| 38 | 35 |
| 39 LayoutTestRenderProcessObserver::LayoutTestRenderProcessObserver() | 36 LayoutTestRenderProcessObserver::LayoutTestRenderProcessObserver() |
| 40 : main_test_runner_(NULL), | 37 : test_delegate_(nullptr) { |
| 41 test_delegate_(NULL) { | |
| 42 CHECK(!g_instance); | 38 CHECK(!g_instance); |
| 43 g_instance = this; | 39 g_instance = this; |
| 44 RenderThread::Get()->AddObserver(this); | 40 RenderThread::Get()->AddObserver(this); |
| 45 EnableRendererLayoutTestMode(); | 41 EnableRendererLayoutTestMode(); |
| 46 | 42 |
| 47 // We always expose GC to layout tests. | 43 // We always expose GC to layout tests. |
| 48 std::string flags("--expose-gc"); | 44 std::string flags("--expose-gc"); |
| 49 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 45 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
| 50 | 46 |
| 51 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 47 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 70 CHECK(g_instance == this); | 66 CHECK(g_instance == this); |
| 71 g_instance = NULL; | 67 g_instance = NULL; |
| 72 } | 68 } |
| 73 | 69 |
| 74 void LayoutTestRenderProcessObserver::SetTestDelegate( | 70 void LayoutTestRenderProcessObserver::SetTestDelegate( |
| 75 test_runner::WebTestDelegate* delegate) { | 71 test_runner::WebTestDelegate* delegate) { |
| 76 test_interfaces_->SetDelegate(delegate); | 72 test_interfaces_->SetDelegate(delegate); |
| 77 test_delegate_ = delegate; | 73 test_delegate_ = delegate; |
| 78 } | 74 } |
| 79 | 75 |
| 80 void LayoutTestRenderProcessObserver::SetMainWindow(RenderView* view) { | |
| 81 BlinkTestRunner* test_runner = BlinkTestRunner::Get(view); | |
| 82 test_interfaces_->SetWebView(view->GetWebView(), test_runner->proxy()); | |
| 83 main_test_runner_ = test_runner; | |
| 84 } | |
| 85 | |
| 86 void LayoutTestRenderProcessObserver::OnRenderProcessShutdown() { | 76 void LayoutTestRenderProcessObserver::OnRenderProcessShutdown() { |
| 87 test_interfaces_.reset(); | 77 test_interfaces_.reset(); |
| 88 } | 78 } |
| 89 | 79 |
| 90 bool LayoutTestRenderProcessObserver::OnControlMessageReceived( | 80 bool LayoutTestRenderProcessObserver::OnControlMessageReceived( |
| 91 const IPC::Message& message) { | 81 const IPC::Message& message) { |
| 92 bool handled = true; | 82 bool handled = true; |
| 93 IPC_BEGIN_MESSAGE_MAP(LayoutTestRenderProcessObserver, message) | 83 IPC_BEGIN_MESSAGE_MAP(LayoutTestRenderProcessObserver, message) |
| 94 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) | 84 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) |
| 95 IPC_MESSAGE_UNHANDLED(handled = false) | 85 IPC_MESSAGE_UNHANDLED(handled = false) |
| 96 IPC_END_MESSAGE_MAP() | 86 IPC_END_MESSAGE_MAP() |
| 97 | 87 |
| 98 return handled; | 88 return handled; |
| 99 } | 89 } |
| 100 | 90 |
| 101 void LayoutTestRenderProcessObserver::OnSetWebKitSourceDir( | 91 void LayoutTestRenderProcessObserver::OnSetWebKitSourceDir( |
| 102 const base::FilePath& webkit_source_dir) { | 92 const base::FilePath& webkit_source_dir) { |
| 103 webkit_source_dir_ = webkit_source_dir; | 93 webkit_source_dir_ = webkit_source_dir; |
| 104 } | 94 } |
| 105 | 95 |
| 106 } // namespace content | 96 } // namespace content |
| OLD | NEW |