OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 class TestEnvironment { | 142 class TestEnvironment { |
143 public: | 143 public: |
144 #if defined(OS_ANDROID) | 144 #if defined(OS_ANDROID) |
145 // Android UI message loop goes through Java, so don't use it in tests. | 145 // Android UI message loop goes through Java, so don't use it in tests. |
146 typedef MessageLoop MessageLoopType; | 146 typedef MessageLoop MessageLoopType; |
147 #else | 147 #else |
148 typedef MessageLoopForUI MessageLoopType; | 148 typedef MessageLoopForUI MessageLoopType; |
149 #endif | 149 #endif |
150 | 150 |
151 TestEnvironment(bool unit_test_mode, | 151 TestEnvironment(bool unit_test_mode, |
152 base::AtExitManager* existing_at_exit_manager) { | 152 base::AtExitManager* existing_at_exit_manager, |
| 153 WebKit::Platform* shadow_platform_support) { |
153 if (unit_test_mode) { | 154 if (unit_test_mode) { |
154 logging::SetLogAssertHandler(UnitTestAssertHandler); | 155 logging::SetLogAssertHandler(UnitTestAssertHandler); |
155 } else { | 156 } else { |
156 // The existing_at_exit_manager must be not NULL. | 157 // The existing_at_exit_manager must be not NULL. |
157 at_exit_manager_.reset(existing_at_exit_manager); | 158 at_exit_manager_.reset(existing_at_exit_manager); |
158 InitLogging(); | 159 InitLogging(); |
159 } | 160 } |
160 main_message_loop_.reset(new MessageLoopType); | 161 main_message_loop_.reset(new MessageLoopType); |
| 162 |
161 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. | 163 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. |
162 webkit_platform_support_.reset( | 164 webkit_platform_support_.reset( |
163 new TestWebKitPlatformSupport(unit_test_mode)); | 165 new TestWebKitPlatformSupport(unit_test_mode, shadow_platform_support)); |
164 | 166 |
165 #if defined(OS_ANDROID) | 167 #if defined(OS_ANDROID) |
166 media_player_manager_.reset( | 168 media_player_manager_.reset( |
167 new webkit_media::WebMediaPlayerManagerAndroid()); | 169 new webkit_media::WebMediaPlayerManagerAndroid()); |
168 #endif | 170 #endif |
169 } | 171 } |
170 | 172 |
171 ~TestEnvironment() { | 173 ~TestEnvironment() { |
172 SimpleResourceLoaderBridge::Shutdown(); | 174 SimpleResourceLoaderBridge::Shutdown(); |
173 } | 175 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 private: | 273 private: |
272 MessageLoop* message_loop_; | 274 MessageLoop* message_loop_; |
273 }; | 275 }; |
274 | 276 |
275 webkit_support::GraphicsContext3DImplementation | 277 webkit_support::GraphicsContext3DImplementation |
276 g_graphics_context_3d_implementation = | 278 g_graphics_context_3d_implementation = |
277 webkit_support::IN_PROCESS_COMMAND_BUFFER; | 279 webkit_support::IN_PROCESS_COMMAND_BUFFER; |
278 | 280 |
279 TestEnvironment* test_environment; | 281 TestEnvironment* test_environment; |
280 | 282 |
281 void SetUpTestEnvironmentImpl(bool unit_test_mode) { | 283 void SetUpTestEnvironmentImpl(bool unit_test_mode, |
| 284 WebKit::Platform* shadow_platform_support) { |
282 base::EnableInProcessStackDumping(); | 285 base::EnableInProcessStackDumping(); |
283 base::EnableTerminationOnHeapCorruption(); | 286 base::EnableTerminationOnHeapCorruption(); |
284 | 287 |
285 // Initialize the singleton CommandLine with fixed values. Some code refer to | 288 // Initialize the singleton CommandLine with fixed values. Some code refer to |
286 // CommandLine::ForCurrentProcess(). We don't use the actual command-line | 289 // CommandLine::ForCurrentProcess(). We don't use the actual command-line |
287 // arguments of DRT to avoid unexpected behavior change. | 290 // arguments of DRT to avoid unexpected behavior change. |
288 // | 291 // |
289 // webkit/glue/plugin/plugin_list_posix.cc checks --debug-plugin-loading. | 292 // webkit/glue/plugin/plugin_list_posix.cc checks --debug-plugin-loading. |
290 // webkit/glue/plugin/plugin_list_win.cc checks --old-wmp. | 293 // webkit/glue/plugin/plugin_list_win.cc checks --old-wmp. |
291 // If DRT needs these flags, specify them in the following kFixedArguments. | 294 // If DRT needs these flags, specify them in the following kFixedArguments. |
292 const char* kFixedArguments[] = {"DumpRenderTree"}; | 295 const char* kFixedArguments[] = {"DumpRenderTree"}; |
293 CommandLine::Init(arraysize(kFixedArguments), kFixedArguments); | 296 CommandLine::Init(arraysize(kFixedArguments), kFixedArguments); |
294 | 297 |
295 // Explicitly initialize the GURL library before spawning any threads. | 298 // Explicitly initialize the GURL library before spawning any threads. |
296 // Otherwise crash may happend when different threads try to create a GURL | 299 // Otherwise crash may happend when different threads try to create a GURL |
297 // at same time. | 300 // at same time. |
298 url_util::Initialize(); | 301 url_util::Initialize(); |
299 base::AtExitManager* at_exit_manager = NULL; | 302 base::AtExitManager* at_exit_manager = NULL; |
300 // In Android DumpRenderTree, AtExitManager is created in | 303 // In Android DumpRenderTree, AtExitManager is created in |
301 // testing/android/native_test_wrapper.cc before main() is called. | 304 // testing/android/native_test_wrapper.cc before main() is called. |
302 #if !defined(OS_ANDROID) | 305 #if !defined(OS_ANDROID) |
303 // Some initialization code may use a AtExitManager before initializing | 306 // Some initialization code may use a AtExitManager before initializing |
304 // TestEnvironment, so we create a AtExitManager early and pass its ownership | 307 // TestEnvironment, so we create a AtExitManager early and pass its ownership |
305 // to TestEnvironment. | 308 // to TestEnvironment. |
306 if (!unit_test_mode) | 309 if (!unit_test_mode) |
307 at_exit_manager = new base::AtExitManager; | 310 at_exit_manager = new base::AtExitManager; |
308 #endif | 311 #endif |
309 webkit_support::BeforeInitialize(unit_test_mode); | 312 webkit_support::BeforeInitialize(unit_test_mode); |
310 test_environment = new TestEnvironment(unit_test_mode, at_exit_manager); | 313 test_environment = new TestEnvironment(unit_test_mode, at_exit_manager, |
| 314 shadow_platform_support); |
311 webkit_support::AfterInitialize(unit_test_mode); | 315 webkit_support::AfterInitialize(unit_test_mode); |
312 if (!unit_test_mode) { | 316 if (!unit_test_mode) { |
313 // Load ICU data tables. This has to run after TestEnvironment is created | 317 // Load ICU data tables. This has to run after TestEnvironment is created |
314 // because on Linux, we need base::AtExitManager. | 318 // because on Linux, we need base::AtExitManager. |
315 icu_util::Initialize(); | 319 icu_util::Initialize(); |
316 } | 320 } |
317 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( | 321 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( |
318 "DumpRenderTree/0.0.0.0"), false); | 322 "DumpRenderTree/0.0.0.0"), false); |
319 } | 323 } |
320 | 324 |
321 } // namespace | 325 } // namespace |
322 | 326 |
323 namespace webkit_support { | 327 namespace webkit_support { |
324 | 328 |
325 void SetUpTestEnvironment() { | 329 void SetUpTestEnvironment(WebKit::Platform* shadow_platform_support) { |
326 SetUpTestEnvironmentImpl(false); | 330 SetUpTestEnvironmentImpl(false, shadow_platform_support); |
327 } | 331 } |
328 | 332 |
329 void SetUpTestEnvironmentForUnitTests() { | 333 void SetUpTestEnvironmentForUnitTests( |
330 SetUpTestEnvironmentImpl(true); | 334 WebKit::Platform* shadow_platform_support) { |
| 335 SetUpTestEnvironmentImpl(true, shadow_platform_support); |
331 } | 336 } |
332 | 337 |
333 void TearDownTestEnvironment() { | 338 void TearDownTestEnvironment() { |
334 // Flush any remaining messages before we kill ourselves. | 339 // Flush any remaining messages before we kill ourselves. |
335 // http://code.google.com/p/chromium/issues/detail?id=9500 | 340 // http://code.google.com/p/chromium/issues/detail?id=9500 |
336 MessageLoop::current()->RunAllPending(); | 341 MessageLoop::current()->RunAllPending(); |
337 | 342 |
338 BeforeShutdown(); | 343 BeforeShutdown(); |
339 if (RunningOnValgrind()) | 344 if (RunningOnValgrind()) |
340 WebKit::WebCache::clear(); | 345 WebKit::WebCache::clear(); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 // Logging | 808 // Logging |
804 void EnableWebCoreLogChannels(const std::string& channels) { | 809 void EnableWebCoreLogChannels(const std::string& channels) { |
805 webkit_glue::EnableWebCoreLogChannels(channels); | 810 webkit_glue::EnableWebCoreLogChannels(channels); |
806 } | 811 } |
807 | 812 |
808 void SetGamepadData(const WebKit::WebGamepads& pads) { | 813 void SetGamepadData(const WebKit::WebGamepads& pads) { |
809 test_environment->webkit_platform_support()->setGamepadData(pads); | 814 test_environment->webkit_platform_support()->setGamepadData(pads); |
810 } | 815 } |
811 | 816 |
812 } // namespace webkit_support | 817 } // namespace webkit_support |
OLD | NEW |