| 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 <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/path_service.h" | |
| 12 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 13 #include "base/strings/string_tokenizer.h" | 12 #include "base/strings/string_tokenizer.h" |
| 14 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/common/user_agent.h" | 14 #include "content/public/common/user_agent.h" |
| 16 #include "content/test/test_webkit_platform_support.h" | 15 #include "content/test/test_webkit_platform_support.h" |
| 17 #include "third_party/WebKit/public/web/WebCache.h" | 16 #include "third_party/WebKit/public/web/WebCache.h" |
| 18 #include "third_party/WebKit/public/web/WebKit.h" | 17 #include "third_party/WebKit/public/web/WebKit.h" |
| 19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 18 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | |
| 21 #include "url/url_util.h" | 19 #include "url/url_util.h" |
| 22 | 20 |
| 21 #if defined(OS_WIN) |
| 22 #include "ui/gfx/win/dpi.h" |
| 23 #endif |
| 24 |
| 23 #if defined(OS_ANDROID) | 25 #if defined(OS_ANDROID) |
| 24 #include "base/android/jni_android.h" | 26 #include "base/android/jni_android.h" |
| 25 #include "net/android/network_library.h" | 27 #include "net/android/network_library.h" |
| 26 #endif | 28 #endif |
| 27 | 29 |
| 28 #if defined(OS_MACOSX) | 30 #if defined(OS_MACOSX) |
| 29 #include "base/test/mock_chrome_application_mac.h" | 31 #include "base/test/mock_chrome_application_mac.h" |
| 30 #endif | 32 #endif |
| 31 | 33 |
| 32 namespace content { | 34 namespace content { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 54 typedef base::MessageLoop MessageLoopType; | 56 typedef base::MessageLoop MessageLoopType; |
| 55 #else | 57 #else |
| 56 typedef base::MessageLoopForUI MessageLoopType; | 58 typedef base::MessageLoopForUI MessageLoopType; |
| 57 #endif | 59 #endif |
| 58 | 60 |
| 59 TestEnvironment() { | 61 TestEnvironment() { |
| 60 main_message_loop_.reset(new MessageLoopType); | 62 main_message_loop_.reset(new MessageLoopType); |
| 61 | 63 |
| 62 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. | 64 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. |
| 63 webkit_platform_support_.reset(new TestWebKitPlatformSupport); | 65 webkit_platform_support_.reset(new TestWebKitPlatformSupport); |
| 64 | |
| 65 #if defined(OS_WIN) | |
| 66 base::FilePath pak_file; | |
| 67 PathService::Get(base::DIR_MODULE, &pak_file); | |
| 68 pak_file = pak_file.AppendASCII("ui_test.pak"); | |
| 69 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file); | |
| 70 #endif | |
| 71 } | 66 } |
| 72 | 67 |
| 73 ~TestEnvironment() { | 68 ~TestEnvironment() { |
| 74 #if defined(OS_WIN) | |
| 75 ui::ResourceBundle::CleanupSharedInstance(); | |
| 76 #endif | |
| 77 } | 69 } |
| 78 | 70 |
| 79 TestWebKitPlatformSupport* webkit_platform_support() const { | 71 TestWebKitPlatformSupport* webkit_platform_support() const { |
| 80 return webkit_platform_support_.get(); | 72 return webkit_platform_support_.get(); |
| 81 } | 73 } |
| 82 | 74 |
| 83 private: | 75 private: |
| 84 scoped_ptr<MessageLoopType> main_message_loop_; | 76 scoped_ptr<MessageLoopType> main_message_loop_; |
| 85 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; | 77 scoped_ptr<TestWebKitPlatformSupport> webkit_platform_support_; |
| 86 }; | 78 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 | 89 |
| 98 #if defined(OS_ANDROID) | 90 #if defined(OS_ANDROID) |
| 99 JNIEnv* env = base::android::AttachCurrentThread(); | 91 JNIEnv* env = base::android::AttachCurrentThread(); |
| 100 net::android::RegisterNetworkLibrary(env); | 92 net::android::RegisterNetworkLibrary(env); |
| 101 #endif | 93 #endif |
| 102 | 94 |
| 103 #if defined(OS_MACOSX) | 95 #if defined(OS_MACOSX) |
| 104 mock_cr_app::RegisterMockCrApp(); | 96 mock_cr_app::RegisterMockCrApp(); |
| 105 #endif | 97 #endif |
| 106 | 98 |
| 99 #if defined(OS_WIN) |
| 100 gfx::InitDeviceScaleFactor(1.0f); |
| 101 #endif |
| 102 |
| 107 // Explicitly initialize the GURL library before spawning any threads. | 103 // Explicitly initialize the GURL library before spawning any threads. |
| 108 // 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 |
| 109 // at same time. | 105 // at same time. |
| 110 url::Initialize(); | 106 url::Initialize(); |
| 111 test_environment = new TestEnvironment; | 107 test_environment = new TestEnvironment; |
| 112 } | 108 } |
| 113 | 109 |
| 114 void TearDownTestEnvironment() { | 110 void TearDownTestEnvironment() { |
| 115 // Flush any remaining messages before we kill ourselves. | 111 // Flush any remaining messages before we kill ourselves. |
| 116 // http://code.google.com/p/chromium/issues/detail?id=9500 | 112 // http://code.google.com/p/chromium/issues/detail?id=9500 |
| 117 base::RunLoop().RunUntilIdle(); | 113 base::RunLoop().RunUntilIdle(); |
| 118 | 114 |
| 119 if (RunningOnValgrind()) | 115 if (RunningOnValgrind()) |
| 120 blink::WebCache::clear(); | 116 blink::WebCache::clear(); |
| 121 delete test_environment; | 117 delete test_environment; |
| 122 test_environment = NULL; | 118 test_environment = NULL; |
| 123 } | 119 } |
| 124 | 120 |
| 125 } // namespace content | 121 } // namespace content |
| OLD | NEW |