Chromium Code Reviews| Index: webkit/support/webkit_support.cc |
| diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc |
| index 048ef4ea46e0837434dd0091c1f7f50fbdf744a6..d4f1d82217551a77b09f5f8f96e7feb57004500e 100644 |
| --- a/webkit/support/webkit_support.cc |
| +++ b/webkit/support/webkit_support.cc |
| @@ -149,7 +149,8 @@ class TestEnvironment { |
| #endif |
| TestEnvironment(bool unit_test_mode, |
| - base::AtExitManager* existing_at_exit_manager) { |
| + base::AtExitManager* existing_at_exit_manager, |
| + const PlatformSupportCreatorCallback& callback) { |
| if (unit_test_mode) { |
| logging::SetLogAssertHandler(UnitTestAssertHandler); |
| } else { |
| @@ -158,9 +159,9 @@ class TestEnvironment { |
| InitLogging(); |
| } |
| main_message_loop_.reset(new MessageLoopType); |
| + |
| // TestWebKitPlatformSupport must be instantiated after MessageLoopType. |
| - webkit_platform_support_.reset( |
| - new TestWebKitPlatformSupport(unit_test_mode)); |
| + webkit_platform_support_.reset(callback.Run(unit_test_mode)); |
|
tommi (sloooow) - chröme
2012/07/09 12:19:29
after calling callback.Run(), you can call callbac
Tommy Widenflycht
2012/07/09 12:25:31
Not possible to call Reset() on it since it is con
|
| #if defined(OS_ANDROID) |
| media_player_manager_.reset( |
| @@ -278,7 +279,8 @@ webkit_support::GraphicsContext3DImplementation |
| TestEnvironment* test_environment; |
| -void SetUpTestEnvironmentImpl(bool unit_test_mode) { |
| +void SetUpTestEnvironmentImpl(const PlatformSupportCreatorCallback& callback, |
| + bool unit_test_mode) { |
| base::EnableInProcessStackDumping(); |
| base::EnableTerminationOnHeapCorruption(); |
| @@ -307,7 +309,8 @@ void SetUpTestEnvironmentImpl(bool unit_test_mode) { |
| at_exit_manager = new base::AtExitManager; |
| #endif |
| webkit_support::BeforeInitialize(unit_test_mode); |
| - test_environment = new TestEnvironment(unit_test_mode, at_exit_manager); |
| + test_environment = |
| + new TestEnvironment(unit_test_mode, at_exit_manager, callback); |
| webkit_support::AfterInitialize(unit_test_mode); |
| if (!unit_test_mode) { |
| // Load ICU data tables. This has to run after TestEnvironment is created |
| @@ -322,12 +325,30 @@ void SetUpTestEnvironmentImpl(bool unit_test_mode) { |
| namespace webkit_support { |
| +TestWebKitPlatformSupport* |
| +CreateDefaultTestWebKitPlatformSupport(bool unit_test_mode) { |
| + return new TestWebKitPlatformSupport(unit_test_mode); |
| +} |
| + |
| void SetUpTestEnvironment() { |
| - SetUpTestEnvironmentImpl(false); |
| + PlatformSupportCreatorCallback callback = |
| + base::Bind(&CreateDefaultTestWebKitPlatformSupport); |
| + SetUpTestEnvironmentImpl(callback, false); |
| } |
| void SetUpTestEnvironmentForUnitTests() { |
| - SetUpTestEnvironmentImpl(true); |
| + PlatformSupportCreatorCallback callback = |
| + base::Bind(&CreateDefaultTestWebKitPlatformSupport); |
| + SetUpTestEnvironmentImpl(callback, true); |
| +} |
| + |
| +void SetUpTestEnvironment(const PlatformSupportCreatorCallback& callback) { |
| + SetUpTestEnvironmentImpl(callback, false); |
| +} |
| + |
| +void SetUpTestEnvironmentForUnitTests( |
| + const PlatformSupportCreatorCallback& callback) { |
| + SetUpTestEnvironmentImpl(callback, true); |
| } |
| void TearDownTestEnvironment() { |