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

Side by Side Diff: content/shell/renderer/layout_test/layout_test_render_thread_observer.cc

Issue 1896623002: Setting TestRunner's main window from BlinkTestRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@replicate-across-all-renderers
Patch Set: Rebasing... Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « content/shell/renderer/layout_test/layout_test_render_thread_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_thread_observer. h" 5 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer. h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "components/test_runner/test_interfaces.h" 8 #include "components/test_runner/test_interfaces.h"
9 #include "components/test_runner/web_test_interfaces.h" 9 #include "components/test_runner/web_test_interfaces.h"
10 #include "components/test_runner/web_test_runner.h" 10 #include "components/test_runner/web_test_runner.h"
11 #include "content/public/common/content_client.h" 11 #include "content/public/common/content_client.h"
12 #include "content/public/renderer/render_thread.h" 12 #include "content/public/renderer/render_thread.h"
13 #include "content/public/test/layouttest_support.h" 13 #include "content/public/test/layouttest_support.h"
14 #include "content/shell/common/layout_test/layout_test_messages.h" 14 #include "content/shell/common/layout_test/layout_test_messages.h"
15 #include "content/shell/common/layout_test/layout_test_switches.h" 15 #include "content/shell/common/layout_test/layout_test_switches.h"
16 #include "content/shell/common/shell_messages.h" 16 #include "content/shell/common/shell_messages.h"
17 #include "content/shell/renderer/layout_test/blink_test_runner.h"
18 #include "third_party/WebKit/public/web/WebKit.h" 17 #include "third_party/WebKit/public/web/WebKit.h"
19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 18 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
20 #include "v8/include/v8.h" 19 #include "v8/include/v8.h"
21 20
22 using blink::WebFrame; 21 using blink::WebFrame;
23 using blink::WebRuntimeFeatures; 22 using blink::WebRuntimeFeatures;
24 23
25 namespace content { 24 namespace content {
26 25
27 namespace { 26 namespace {
28 LayoutTestRenderThreadObserver* g_instance = NULL; 27 LayoutTestRenderThreadObserver* g_instance = NULL;
29 } 28 }
30 29
31 // static 30 // static
32 LayoutTestRenderThreadObserver* 31 LayoutTestRenderThreadObserver*
33 LayoutTestRenderThreadObserver::GetInstance() { 32 LayoutTestRenderThreadObserver::GetInstance() {
34 return g_instance; 33 return g_instance;
35 } 34 }
36 35
37 LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() 36 LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() {
38 : test_delegate_(nullptr) {
39 CHECK(!g_instance); 37 CHECK(!g_instance);
40 g_instance = this; 38 g_instance = this;
41 RenderThread::Get()->AddObserver(this); 39 RenderThread::Get()->AddObserver(this);
42 EnableRendererLayoutTestMode(); 40 EnableRendererLayoutTestMode();
43 41
44 // We always expose GC to layout tests. 42 // We always expose GC to layout tests.
45 std::string flags("--expose-gc"); 43 std::string flags("--expose-gc");
46 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); 44 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
47 45
48 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 46 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 11 matching lines...) Expand all
60 switches::kAlwaysUseComplexText)) { 58 switches::kAlwaysUseComplexText)) {
61 blink::setAlwaysUseComplexTextForTest(true); 59 blink::setAlwaysUseComplexTextForTest(true);
62 } 60 }
63 } 61 }
64 62
65 LayoutTestRenderThreadObserver::~LayoutTestRenderThreadObserver() { 63 LayoutTestRenderThreadObserver::~LayoutTestRenderThreadObserver() {
66 CHECK(g_instance == this); 64 CHECK(g_instance == this);
67 g_instance = NULL; 65 g_instance = NULL;
68 } 66 }
69 67
70 void LayoutTestRenderThreadObserver::SetTestDelegate(
71 test_runner::WebTestDelegate* delegate) {
72 test_interfaces_->SetDelegate(delegate);
73 test_delegate_ = delegate;
74 }
75
76 void LayoutTestRenderThreadObserver::OnRenderProcessShutdown() { 68 void LayoutTestRenderThreadObserver::OnRenderProcessShutdown() {
77 test_interfaces_.reset(); 69 test_interfaces_.reset();
78 } 70 }
79 71
80 bool LayoutTestRenderThreadObserver::OnControlMessageReceived( 72 bool LayoutTestRenderThreadObserver::OnControlMessageReceived(
81 const IPC::Message& message) { 73 const IPC::Message& message) {
82 bool handled = true; 74 bool handled = true;
83 IPC_BEGIN_MESSAGE_MAP(LayoutTestRenderThreadObserver, message) 75 IPC_BEGIN_MESSAGE_MAP(LayoutTestRenderThreadObserver, message)
84 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) 76 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir)
85 IPC_MESSAGE_HANDLER(LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges, 77 IPC_MESSAGE_HANDLER(LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges,
86 OnReplicateLayoutTestRuntimeFlagsChanges) 78 OnReplicateLayoutTestRuntimeFlagsChanges)
87 IPC_MESSAGE_UNHANDLED(handled = false) 79 IPC_MESSAGE_UNHANDLED(handled = false)
88 IPC_END_MESSAGE_MAP() 80 IPC_END_MESSAGE_MAP()
89 81
90 return handled; 82 return handled;
91 } 83 }
92 84
93 void LayoutTestRenderThreadObserver::OnSetWebKitSourceDir( 85 void LayoutTestRenderThreadObserver::OnSetWebKitSourceDir(
94 const base::FilePath& webkit_source_dir) { 86 const base::FilePath& webkit_source_dir) {
95 webkit_source_dir_ = webkit_source_dir; 87 webkit_source_dir_ = webkit_source_dir;
96 } 88 }
97 89
98 void LayoutTestRenderThreadObserver::OnReplicateLayoutTestRuntimeFlagsChanges( 90 void LayoutTestRenderThreadObserver::OnReplicateLayoutTestRuntimeFlagsChanges(
99 const base::DictionaryValue& changed_layout_test_runtime_flags) { 91 const base::DictionaryValue& changed_layout_test_runtime_flags) {
100 test_interfaces()->TestRunner()->ReplicateLayoutTestRuntimeFlagsChanges( 92 test_interfaces()->TestRunner()->ReplicateLayoutTestRuntimeFlagsChanges(
101 changed_layout_test_runtime_flags); 93 changed_layout_test_runtime_flags);
102 } 94 }
103 95
104 } // namespace content 96 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/layout_test/layout_test_render_thread_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698