| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/webkit_support.h" | 5 #include "content/test/blink_test_environment.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/string_tokenizer.h" | 12 #include "base/strings/string_tokenizer.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/common/user_agent.h" | 14 #include "content/public/common/user_agent.h" |
| 15 #include "content/test/test_webkit_platform_support.h" | 15 #include "content/test/test_webkit_platform_support.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 scoped_ptr<MessageLoopType> main_message_loop_; | 76 scoped_ptr<MessageLoopType> main_message_loop_; |
| 77 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; | 77 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 TestEnvironment* test_environment; | 80 TestEnvironment* test_environment; |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 void SetUpTestEnvironmentForUnitTests() { | 84 void SetUpBlinkTestEnvironment() { |
| 85 ParseBlinkCommandLineArgumentsForUnitTests(); | 85 ParseBlinkCommandLineArgumentsForUnitTests(); |
| 86 | 86 |
| 87 blink::WebRuntimeFeatures::enableExperimentalFeatures(true); | 87 blink::WebRuntimeFeatures::enableExperimentalFeatures(true); |
| 88 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); | 88 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); |
| 89 | 89 |
| 90 #if defined(OS_ANDROID) | 90 #if defined(OS_ANDROID) |
| 91 JNIEnv* env = base::android::AttachCurrentThread(); | 91 JNIEnv* env = base::android::AttachCurrentThread(); |
| 92 net::android::RegisterNetworkLibrary(env); | 92 net::android::RegisterNetworkLibrary(env); |
| 93 #endif | 93 #endif |
| 94 | 94 |
| 95 #if defined(OS_MACOSX) | 95 #if defined(OS_MACOSX) |
| 96 mock_cr_app::RegisterMockCrApp(); | 96 mock_cr_app::RegisterMockCrApp(); |
| 97 #endif | 97 #endif |
| 98 | 98 |
| 99 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
| 100 gfx::InitDeviceScaleFactor(1.0f); | 100 gfx::InitDeviceScaleFactor(1.0f); |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 // Explicitly initialize the GURL library before spawning any threads. | 103 // Explicitly initialize the GURL library before spawning any threads. |
| 104 // Otherwise crash may happend when different threads try to create a GURL | 104 // Otherwise crash may happend when different threads try to create a GURL |
| 105 // at same time. | 105 // at same time. |
| 106 url::Initialize(); | 106 url::Initialize(); |
| 107 test_environment = new TestEnvironment; | 107 test_environment = new TestEnvironment; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void TearDownTestEnvironment() { | 110 void TearDownBlinkTestEnvironment() { |
| 111 // Flush any remaining messages before we kill ourselves. | 111 // Flush any remaining messages before we kill ourselves. |
| 112 // http://code.google.com/p/chromium/issues/detail?id=9500 | 112 // http://code.google.com/p/chromium/issues/detail?id=9500 |
| 113 base::RunLoop().RunUntilIdle(); | 113 base::RunLoop().RunUntilIdle(); |
| 114 | 114 |
| 115 if (RunningOnValgrind()) | 115 if (RunningOnValgrind()) |
| 116 blink::WebCache::clear(); | 116 blink::WebCache::clear(); |
| 117 delete test_environment; | 117 delete test_environment; |
| 118 test_environment = NULL; | 118 test_environment = NULL; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void SetUpTestEnvironmentForUnitTests() { |
| 122 SetUpBlinkTestEnvironment(); |
| 123 } |
| 124 |
| 125 void TearDownTestEnvironment() { |
| 126 TearDownBlinkTestEnvironment(); |
| 127 } |
| 128 |
| 121 } // namespace content | 129 } // namespace content |
| OLD | NEW |