| 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/webkit_support.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "content/test/test_webkit_platform_support.h" | 9 #include "content/test/test_webkit_platform_support.h" |
| 10 #include "third_party/WebKit/public/web/WebCache.h" | 10 #include "third_party/WebKit/public/web/WebCache.h" |
| 11 #include "third_party/WebKit/public/web/WebKit.h" | 11 #include "third_party/WebKit/public/web/WebKit.h" |
| 12 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 12 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 13 #include "url/url_util.h" | 13 #include "url/url_util.h" |
| 14 #include "webkit/common/user_agent/user_agent.h" | 14 #include "webkit/common/user_agent/user_agent.h" |
| 15 #include "webkit/common/user_agent/user_agent_util.h" | 15 #include "webkit/common/user_agent/user_agent_util.h" |
| 16 | 16 |
| 17 #if defined(OS_ANDROID) | 17 #if defined(OS_ANDROID) |
| 18 #include "base/android/jni_android.h" | 18 #include "base/android/jni_android.h" |
| 19 #include "net/android/network_library.h" | 19 #include "net/android/network_library.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #if defined(OS_MACOSX) | 22 #if defined(OS_MACOSX) |
| 23 #include "base/test/mock_chrome_application_mac.h" | 23 #include "base/test/mock_chrome_application_mac.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 namespace content { |
| 27 |
| 26 namespace { | 28 namespace { |
| 27 | 29 |
| 28 class TestEnvironment { | 30 class TestEnvironment { |
| 29 public: | 31 public: |
| 30 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
| 31 // Android UI message loop goes through Java, so don't use it in tests. | 33 // Android UI message loop goes through Java, so don't use it in tests. |
| 32 typedef base::MessageLoop MessageLoopType; | 34 typedef base::MessageLoop MessageLoopType; |
| 33 #else | 35 #else |
| 34 typedef base::MessageLoopForUI MessageLoopType; | 36 typedef base::MessageLoopForUI MessageLoopType; |
| 35 #endif | 37 #endif |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 | 49 |
| 48 private: | 50 private: |
| 49 scoped_ptr<MessageLoopType> main_message_loop_; | 51 scoped_ptr<MessageLoopType> main_message_loop_; |
| 50 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; | 52 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 TestEnvironment* test_environment; | 55 TestEnvironment* test_environment; |
| 54 | 56 |
| 55 } // namespace | 57 } // namespace |
| 56 | 58 |
| 57 namespace webkit_support { | |
| 58 | |
| 59 void SetUpTestEnvironmentForUnitTests() { | 59 void SetUpTestEnvironmentForUnitTests() { |
| 60 WebKit::WebRuntimeFeatures::enableStableFeatures(true); | 60 WebKit::WebRuntimeFeatures::enableStableFeatures(true); |
| 61 WebKit::WebRuntimeFeatures::enableExperimentalFeatures(true); | 61 WebKit::WebRuntimeFeatures::enableExperimentalFeatures(true); |
| 62 WebKit::WebRuntimeFeatures::enableTestOnlyFeatures(true); | 62 WebKit::WebRuntimeFeatures::enableTestOnlyFeatures(true); |
| 63 | 63 |
| 64 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
| 65 JNIEnv* env = base::android::AttachCurrentThread(); | 65 JNIEnv* env = base::android::AttachCurrentThread(); |
| 66 net::android::RegisterNetworkLibrary(env); | 66 net::android::RegisterNetworkLibrary(env); |
| 67 #endif | 67 #endif |
| 68 | 68 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 84 // http://code.google.com/p/chromium/issues/detail?id=9500 | 84 // http://code.google.com/p/chromium/issues/detail?id=9500 |
| 85 base::RunLoop().RunUntilIdle(); | 85 base::RunLoop().RunUntilIdle(); |
| 86 | 86 |
| 87 if (RunningOnValgrind()) | 87 if (RunningOnValgrind()) |
| 88 WebKit::WebCache::clear(); | 88 WebKit::WebCache::clear(); |
| 89 WebKit::shutdown(); | 89 WebKit::shutdown(); |
| 90 delete test_environment; | 90 delete test_environment; |
| 91 test_environment = NULL; | 91 test_environment = NULL; |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace webkit_support | 94 } // namespace content |
| OLD | NEW |