OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/support/webkit_support.h" | 5 #include "webkit/support/webkit_support.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 120 |
121 class TestEnvironment { | 121 class TestEnvironment { |
122 public: | 122 public: |
123 #if defined(OS_ANDROID) | 123 #if defined(OS_ANDROID) |
124 // Android UI message loop goes through Java, so don't use it in tests. | 124 // Android UI message loop goes through Java, so don't use it in tests. |
125 typedef MessageLoop MessageLoopType; | 125 typedef MessageLoop MessageLoopType; |
126 #else | 126 #else |
127 typedef MessageLoopForUI MessageLoopType; | 127 typedef MessageLoopForUI MessageLoopType; |
128 #endif | 128 #endif |
129 | 129 |
130 explicit TestEnvironment(bool unit_test_mode) { | 130 // Sometimes we have to create a AtExitManager before initializing |
131 // TestEnvironment. Give TestEnvironment a chance to reuse existing | |
132 // AtExitManager if needed. | |
133 explicit TestEnvironment(bool unit_test_mode, | |
tony
2011/11/22 17:28:55
Nit: No explicit.
Johnny(Jianning) Ding
2011/11/23 14:52:17
Done.
| |
134 base::AtExitManager* existing_at_exit_manager) { | |
131 if (!unit_test_mode) { | 135 if (!unit_test_mode) { |
132 at_exit_manager_.reset(new base::AtExitManager); | 136 if (!existing_at_exit_manager) |
137 existing_at_exit_manager = new base::AtExitManager; | |
138 at_exit_manager_.reset(existing_at_exit_manager); | |
133 InitLogging(false); | 139 InitLogging(false); |
134 } | 140 } |
135 main_message_loop_.reset(new MessageLoopType); | 141 main_message_loop_.reset(new MessageLoopType); |
136 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. | 142 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. |
137 webkit_platform_support_.reset( | 143 webkit_platform_support_.reset( |
138 new TestWebKitPlatformSupport(unit_test_mode)); | 144 new TestWebKitPlatformSupport(unit_test_mode)); |
139 } | 145 } |
140 | 146 |
141 ~TestEnvironment() { | 147 ~TestEnvironment() { |
142 SimpleResourceLoaderBridge::Shutdown(); | 148 SimpleResourceLoaderBridge::Shutdown(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 // webkit/glue/plugin/plugin_list_posix.cc checks --debug-plugin-loading. | 236 // webkit/glue/plugin/plugin_list_posix.cc checks --debug-plugin-loading. |
231 // webkit/glue/plugin/plugin_list_win.cc checks --old-wmp. | 237 // webkit/glue/plugin/plugin_list_win.cc checks --old-wmp. |
232 // If DRT needs these flags, specify them in the following kFixedArguments. | 238 // If DRT needs these flags, specify them in the following kFixedArguments. |
233 const char* kFixedArguments[] = {"DumpRenderTree"}; | 239 const char* kFixedArguments[] = {"DumpRenderTree"}; |
234 CommandLine::Init(arraysize(kFixedArguments), kFixedArguments); | 240 CommandLine::Init(arraysize(kFixedArguments), kFixedArguments); |
235 | 241 |
236 // Explicitly initialize the GURL library before spawning any threads. | 242 // Explicitly initialize the GURL library before spawning any threads. |
237 // Otherwise crash may happend when different threads try to create a GURL | 243 // Otherwise crash may happend when different threads try to create a GURL |
238 // at same time. | 244 // at same time. |
239 url_util::Initialize(); | 245 url_util::Initialize(); |
246 base::AtExitManager* at_exit_manager = NULL; | |
tony
2011/11/22 17:28:55
Can we just have all ports create the at_exit_mana
Johnny(Jianning) Ding
2011/11/23 14:52:17
Done.
| |
247 #if defined(OS_ANDROID) | |
248 // We need to register Android specific paths in BeforeInitialize routine | |
249 // which are needed by TestEnvironment. Since PathService need a AtExitManager | |
250 // to register a callback, (See LazyInstanceHelper::CompleteInstance.) we need | |
251 // to create a AtExitManager before initializing TestEnvironment. We will pass | |
252 // the ownership of the AtExitManager to TestEnvironment constructor to let | |
253 // the TestEnvironment instance manage its lifecycle. | |
254 at_exit_manager = new base::AtExitManager; | |
255 #endif | |
240 BeforeInitialize(unit_test_mode); | 256 BeforeInitialize(unit_test_mode); |
241 test_environment = new TestEnvironment(unit_test_mode); | 257 test_environment = new TestEnvironment(unit_test_mode, at_exit_manager); |
242 AfterInitialize(unit_test_mode); | 258 AfterInitialize(unit_test_mode); |
243 if (!unit_test_mode) { | 259 if (!unit_test_mode) { |
244 // Load ICU data tables. This has to run after TestEnvironment is created | 260 // Load ICU data tables. This has to run after TestEnvironment is created |
245 // because on Linux, we need base::AtExitManager. | 261 // because on Linux, we need base::AtExitManager. |
246 icu_util::Initialize(); | 262 icu_util::Initialize(); |
247 } | 263 } |
248 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( | 264 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( |
249 "DumpRenderTree/0.0.0.0"), false); | 265 "DumpRenderTree/0.0.0.0"), false); |
250 } | 266 } |
251 | 267 |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 // Logging | 642 // Logging |
627 void EnableWebCoreLogChannels(const std::string& channels) { | 643 void EnableWebCoreLogChannels(const std::string& channels) { |
628 webkit_glue::EnableWebCoreLogChannels(channels); | 644 webkit_glue::EnableWebCoreLogChannels(channels); |
629 } | 645 } |
630 | 646 |
631 void SetGamepadData(const WebKit::WebGamepads& pads) { | 647 void SetGamepadData(const WebKit::WebGamepads& pads) { |
632 test_environment->webkit_platform_support()->setGamepadData(pads); | 648 test_environment->webkit_platform_support()->setGamepadData(pads); |
633 } | 649 } |
634 | 650 |
635 } // namespace webkit_support | 651 } // namespace webkit_support |
OLD | NEW |