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_thread_observer.
h" | 5 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer.
h" |
6 | 6 |
7 #include "base/command_line.h" | |
8 #include "components/test_runner/test_interfaces.h" | 7 #include "components/test_runner/test_interfaces.h" |
9 #include "components/test_runner/web_test_interfaces.h" | 8 #include "components/test_runner/web_test_interfaces.h" |
10 #include "components/test_runner/web_test_runner.h" | 9 #include "components/test_runner/web_test_runner.h" |
11 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
12 #include "content/public/renderer/render_thread.h" | 11 #include "content/public/renderer/render_thread.h" |
13 #include "content/public/test/layouttest_support.h" | 12 #include "content/public/test/layouttest_support.h" |
14 #include "content/shell/common/layout_test/layout_test_messages.h" | 13 #include "content/shell/common/layout_test/layout_test_messages.h" |
15 #include "content/shell/common/layout_test/layout_test_switches.h" | 14 #include "content/shell/common/layout_test/layout_test_switches.h" |
16 #include "content/shell/common/shell_messages.h" | 15 #include "content/shell/common/shell_messages.h" |
17 #include "third_party/WebKit/public/web/WebKit.h" | |
18 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | |
19 #include "v8/include/v8.h" | |
20 | |
21 using blink::WebFrame; | |
22 using blink::WebRuntimeFeatures; | |
23 | 16 |
24 namespace content { | 17 namespace content { |
25 | 18 |
26 namespace { | 19 namespace { |
27 LayoutTestRenderThreadObserver* g_instance = NULL; | 20 LayoutTestRenderThreadObserver* g_instance = NULL; |
28 } | 21 } |
29 | 22 |
30 // static | 23 // static |
31 LayoutTestRenderThreadObserver* | 24 LayoutTestRenderThreadObserver* |
32 LayoutTestRenderThreadObserver::GetInstance() { | 25 LayoutTestRenderThreadObserver::GetInstance() { |
33 return g_instance; | 26 return g_instance; |
34 } | 27 } |
35 | 28 |
36 LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() { | 29 LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() { |
37 CHECK(!g_instance); | 30 CHECK(!g_instance); |
38 g_instance = this; | 31 g_instance = this; |
39 RenderThread::Get()->AddObserver(this); | 32 RenderThread::Get()->AddObserver(this); |
40 EnableRendererLayoutTestMode(); | |
41 | |
42 // We always expose GC to layout tests. | |
43 std::string flags("--expose-gc"); | |
44 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | |
45 | |
46 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
47 switches::kStableReleaseMode)) { | |
48 WebRuntimeFeatures::enableTestOnlyFeatures(true); | |
49 } | |
50 | 33 |
51 test_interfaces_.reset(new test_runner::WebTestInterfaces); | 34 test_interfaces_.reset(new test_runner::WebTestInterfaces); |
52 test_interfaces_->ResetAll(); | 35 test_interfaces_->ResetAll(); |
53 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
54 switches::kEnableFontAntialiasing)) { | |
55 blink::setFontAntialiasingEnabledForTest(true); | |
56 } | |
57 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
58 switches::kAlwaysUseComplexText)) { | |
59 blink::setAlwaysUseComplexTextForTest(true); | |
60 } | |
61 } | 36 } |
62 | 37 |
63 LayoutTestRenderThreadObserver::~LayoutTestRenderThreadObserver() { | 38 LayoutTestRenderThreadObserver::~LayoutTestRenderThreadObserver() { |
64 CHECK(g_instance == this); | 39 CHECK(g_instance == this); |
65 g_instance = NULL; | 40 g_instance = NULL; |
66 } | 41 } |
67 | 42 |
68 void LayoutTestRenderThreadObserver::OnRenderProcessShutdown() { | 43 void LayoutTestRenderThreadObserver::OnRenderProcessShutdown() { |
69 test_interfaces_.reset(); | 44 test_interfaces_.reset(); |
70 } | 45 } |
(...skipping 16 matching lines...) Expand all Loading... |
87 webkit_source_dir_ = webkit_source_dir; | 62 webkit_source_dir_ = webkit_source_dir; |
88 } | 63 } |
89 | 64 |
90 void LayoutTestRenderThreadObserver::OnReplicateLayoutTestRuntimeFlagsChanges( | 65 void LayoutTestRenderThreadObserver::OnReplicateLayoutTestRuntimeFlagsChanges( |
91 const base::DictionaryValue& changed_layout_test_runtime_flags) { | 66 const base::DictionaryValue& changed_layout_test_runtime_flags) { |
92 test_interfaces()->TestRunner()->ReplicateLayoutTestRuntimeFlagsChanges( | 67 test_interfaces()->TestRunner()->ReplicateLayoutTestRuntimeFlagsChanges( |
93 changed_layout_test_runtime_flags); | 68 changed_layout_test_runtime_flags); |
94 } | 69 } |
95 | 70 |
96 } // namespace content | 71 } // namespace content |
OLD | NEW |