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