| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // The existing_at_exit_manager must be not NULL. | 163 // The existing_at_exit_manager must be not NULL. |
| 164 at_exit_manager_.reset(existing_at_exit_manager); | 164 at_exit_manager_.reset(existing_at_exit_manager); |
| 165 InitLogging(); | 165 InitLogging(); |
| 166 } | 166 } |
| 167 main_message_loop_.reset(new MessageLoopType); | 167 main_message_loop_.reset(new MessageLoopType); |
| 168 | 168 |
| 169 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. | 169 // TestWebKitPlatformSupport must be instantiated after MessageLoopType. |
| 170 webkit_platform_support_.reset( | 170 webkit_platform_support_.reset( |
| 171 new TestWebKitPlatformSupport(unit_test_mode, | 171 new TestWebKitPlatformSupport(unit_test_mode, |
| 172 shadow_platform_delegate)); | 172 shadow_platform_delegate)); |
| 173 WebKit::setIDBFactory(webkit_platform_support_->idbFactory()); |
| 173 | 174 |
| 174 #if defined(OS_ANDROID) | 175 #if defined(OS_ANDROID) |
| 175 // Make sure we have enough decoding resources for layout tests. | 176 // Make sure we have enough decoding resources for layout tests. |
| 176 // The current maximum number of media elements in a layout test is 8. | 177 // The current maximum number of media elements in a layout test is 8. |
| 177 media_bridge_manager_.reset( | 178 media_bridge_manager_.reset( |
| 178 new webkit_media::MediaPlayerBridgeManagerImpl(8)); | 179 new webkit_media::MediaPlayerBridgeManagerImpl(8)); |
| 179 media_player_manager_.reset( | 180 media_player_manager_.reset( |
| 180 new webkit_media::WebMediaPlayerManagerAndroid()); | 181 new webkit_media::WebMediaPlayerManagerAndroid()); |
| 181 #endif | 182 #endif |
| 182 } | 183 } |
| 183 | 184 |
| 184 ~TestEnvironment() { | 185 ~TestEnvironment() { |
| 185 SimpleResourceLoaderBridge::Shutdown(); | 186 SimpleResourceLoaderBridge::Shutdown(); |
| 186 } | 187 } |
| 187 | 188 |
| 189 void Reset() { |
| 190 #if defined(OS_ANDROID) |
| 191 media_player_manager_->ReleaseMediaResources(); |
| 192 #endif |
| 193 WebKit::setIDBFactory(webkit_platform_support_->idbFactory()); |
| 194 } |
| 195 |
| 188 TestWebKitPlatformSupport* webkit_platform_support() const { | 196 TestWebKitPlatformSupport* webkit_platform_support() const { |
| 189 return webkit_platform_support_.get(); | 197 return webkit_platform_support_.get(); |
| 190 } | 198 } |
| 191 | 199 |
| 192 #if defined(OS_WIN) || defined(OS_MACOSX) | 200 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 193 void set_theme_engine(WebKit::WebThemeEngine* engine) { | 201 void set_theme_engine(WebKit::WebThemeEngine* engine) { |
| 194 DCHECK(webkit_platform_support_ != 0); | 202 DCHECK(webkit_platform_support_ != 0); |
| 195 webkit_platform_support_->SetThemeEngine(engine); | 203 webkit_platform_support_->SetThemeEngine(engine); |
| 196 } | 204 } |
| 197 | 205 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 BeforeShutdown(); | 375 BeforeShutdown(); |
| 368 if (RunningOnValgrind()) | 376 if (RunningOnValgrind()) |
| 369 WebKit::WebCache::clear(); | 377 WebKit::WebCache::clear(); |
| 370 WebKit::shutdown(); | 378 WebKit::shutdown(); |
| 371 delete test_environment; | 379 delete test_environment; |
| 372 test_environment = NULL; | 380 test_environment = NULL; |
| 373 AfterShutdown(); | 381 AfterShutdown(); |
| 374 logging::CloseLogFile(); | 382 logging::CloseLogFile(); |
| 375 } | 383 } |
| 376 | 384 |
| 385 void ResetTestEnvironment() { |
| 386 test_environment->Reset(); |
| 387 } |
| 388 |
| 377 WebKit::WebKitPlatformSupport* GetWebKitPlatformSupport() { | 389 WebKit::WebKitPlatformSupport* GetWebKitPlatformSupport() { |
| 378 DCHECK(test_environment); | 390 DCHECK(test_environment); |
| 379 return test_environment->webkit_platform_support(); | 391 return test_environment->webkit_platform_support(); |
| 380 } | 392 } |
| 381 | 393 |
| 382 WebPlugin* CreateWebPlugin(WebFrame* frame, | 394 WebPlugin* CreateWebPlugin(WebFrame* frame, |
| 383 const WebPluginParams& params) { | 395 const WebPluginParams& params) { |
| 384 const bool kAllowWildcard = true; | 396 const bool kAllowWildcard = true; |
| 385 std::vector<webkit::WebPluginInfo> plugins; | 397 std::vector<webkit::WebPluginInfo> plugins; |
| 386 std::vector<std::string> mime_types; | 398 std::vector<std::string> mime_types; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 #endif | 442 #endif |
| 431 } | 443 } |
| 432 | 444 |
| 433 WebKit::WebMediaPlayer* CreateMediaPlayer( | 445 WebKit::WebMediaPlayer* CreateMediaPlayer( |
| 434 WebFrame* frame, | 446 WebFrame* frame, |
| 435 const WebURL& url, | 447 const WebURL& url, |
| 436 WebMediaPlayerClient* client) { | 448 WebMediaPlayerClient* client) { |
| 437 return CreateMediaPlayer(frame, url, client, NULL); | 449 return CreateMediaPlayer(frame, url, client, NULL); |
| 438 } | 450 } |
| 439 | 451 |
| 440 #if defined(OS_ANDROID) | |
| 441 void ReleaseMediaResources() { | |
| 442 test_environment->media_player_manager()->ReleaseMediaResources(); | |
| 443 } | |
| 444 #endif | |
| 445 | |
| 446 WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( | 452 WebKit::WebApplicationCacheHost* CreateApplicationCacheHost( |
| 447 WebFrame*, WebKit::WebApplicationCacheHostClient* client) { | 453 WebFrame*, WebKit::WebApplicationCacheHostClient* client) { |
| 448 return SimpleAppCacheSystem::CreateApplicationCacheHost(client); | 454 return SimpleAppCacheSystem::CreateApplicationCacheHost(client); |
| 449 } | 455 } |
| 450 | 456 |
| 451 WebKit::WebStorageNamespace* CreateSessionStorageNamespace(unsigned quota) { | 457 WebKit::WebStorageNamespace* CreateSessionStorageNamespace(unsigned quota) { |
| 452 return SimpleDomStorageSystem::instance().CreateSessionStorageNamespace(); | 458 return SimpleDomStorageSystem::instance().CreateSessionStorageNamespace(); |
| 453 } | 459 } |
| 454 | 460 |
| 455 WebKit::WebString GetWebKitRootDir() { | 461 WebKit::WebString GetWebKitRootDir() { |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 // Logging | 869 // Logging |
| 864 void EnableWebCoreLogChannels(const std::string& channels) { | 870 void EnableWebCoreLogChannels(const std::string& channels) { |
| 865 webkit_glue::EnableWebCoreLogChannels(channels); | 871 webkit_glue::EnableWebCoreLogChannels(channels); |
| 866 } | 872 } |
| 867 | 873 |
| 868 void SetGamepadData(const WebKit::WebGamepads& pads) { | 874 void SetGamepadData(const WebKit::WebGamepads& pads) { |
| 869 test_environment->webkit_platform_support()->setGamepadData(pads); | 875 test_environment->webkit_platform_support()->setGamepadData(pads); |
| 870 } | 876 } |
| 871 | 877 |
| 872 } // namespace webkit_support | 878 } // namespace webkit_support |
| OLD | NEW |