| 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" | 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 "third_party/WebKit/public/web/WebKit.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" | 18 #include "v8/include/v8.h" |
| 20 | 19 |
| 21 using blink::WebFrame; | 20 using blink::WebFrame; |
| 22 using blink::WebRuntimeFeatures; | |
| 23 | 21 |
| 24 namespace content { | 22 namespace content { |
| 25 | 23 |
| 26 namespace { | 24 namespace { |
| 27 LayoutTestRenderThreadObserver* g_instance = NULL; | 25 LayoutTestRenderThreadObserver* g_instance = NULL; |
| 28 } | 26 } |
| 29 | 27 |
| 30 // static | 28 // static |
| 31 LayoutTestRenderThreadObserver* | 29 LayoutTestRenderThreadObserver* |
| 32 LayoutTestRenderThreadObserver::GetInstance() { | 30 LayoutTestRenderThreadObserver::GetInstance() { |
| 33 return g_instance; | 31 return g_instance; |
| 34 } | 32 } |
| 35 | 33 |
| 36 LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() { | 34 LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() { |
| 37 CHECK(!g_instance); | 35 CHECK(!g_instance); |
| 38 g_instance = this; | 36 g_instance = this; |
| 39 RenderThread::Get()->AddObserver(this); | 37 RenderThread::Get()->AddObserver(this); |
| 40 EnableRendererLayoutTestMode(); | 38 EnableRendererLayoutTestMode(); |
| 41 | 39 |
| 42 // We always expose GC to layout tests. | 40 // We always expose GC to layout tests. |
| 43 std::string flags("--expose-gc"); | 41 std::string flags("--expose-gc"); |
| 44 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 42 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
| 45 | 43 |
| 46 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 47 switches::kStableReleaseMode)) { | |
| 48 WebRuntimeFeatures::enableTestOnlyFeatures(true); | |
| 49 } | |
| 50 | |
| 51 test_interfaces_.reset(new test_runner::WebTestInterfaces); | 44 test_interfaces_.reset(new test_runner::WebTestInterfaces); |
| 52 test_interfaces_->ResetAll(); | 45 test_interfaces_->ResetAll(); |
| 53 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 46 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 54 switches::kEnableFontAntialiasing)) { | 47 switches::kEnableFontAntialiasing)) { |
| 55 blink::setFontAntialiasingEnabledForTest(true); | 48 blink::setFontAntialiasingEnabledForTest(true); |
| 56 } | 49 } |
| 57 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 50 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 58 switches::kAlwaysUseComplexText)) { | 51 switches::kAlwaysUseComplexText)) { |
| 59 blink::setAlwaysUseComplexTextForTest(true); | 52 blink::setAlwaysUseComplexTextForTest(true); |
| 60 } | 53 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 87 webkit_source_dir_ = webkit_source_dir; | 80 webkit_source_dir_ = webkit_source_dir; |
| 88 } | 81 } |
| 89 | 82 |
| 90 void LayoutTestRenderThreadObserver::OnReplicateLayoutTestRuntimeFlagsChanges( | 83 void LayoutTestRenderThreadObserver::OnReplicateLayoutTestRuntimeFlagsChanges( |
| 91 const base::DictionaryValue& changed_layout_test_runtime_flags) { | 84 const base::DictionaryValue& changed_layout_test_runtime_flags) { |
| 92 test_interfaces()->TestRunner()->ReplicateLayoutTestRuntimeFlagsChanges( | 85 test_interfaces()->TestRunner()->ReplicateLayoutTestRuntimeFlagsChanges( |
| 93 changed_layout_test_runtime_flags); | 86 changed_layout_test_runtime_flags); |
| 94 } | 87 } |
| 95 | 88 |
| 96 } // namespace content | 89 } // namespace content |
| OLD | NEW |