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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 173 |
| 174 // TODO(darin): Uncomment this once DRT calls ResetTestEnvironment(). |
| 175 //WebKit::setIDBFactory(webkit_platform_support_->idbFactory()); |
| 176 |
174 #if defined(OS_ANDROID) | 177 #if defined(OS_ANDROID) |
175 // Make sure we have enough decoding resources for layout tests. | 178 // Make sure we have enough decoding resources for layout tests. |
176 // The current maximum number of media elements in a layout test is 8. | 179 // The current maximum number of media elements in a layout test is 8. |
177 media_bridge_manager_.reset( | 180 media_bridge_manager_.reset( |
178 new webkit_media::MediaPlayerBridgeManagerImpl(8)); | 181 new webkit_media::MediaPlayerBridgeManagerImpl(8)); |
179 media_player_manager_.reset( | 182 media_player_manager_.reset( |
180 new webkit_media::WebMediaPlayerManagerAndroid()); | 183 new webkit_media::WebMediaPlayerManagerAndroid()); |
181 #endif | 184 #endif |
182 } | 185 } |
183 | 186 |
184 ~TestEnvironment() { | 187 ~TestEnvironment() { |
185 SimpleResourceLoaderBridge::Shutdown(); | 188 SimpleResourceLoaderBridge::Shutdown(); |
186 } | 189 } |
187 | 190 |
| 191 void Reset() { |
| 192 #if defined(OS_ANDROID) |
| 193 media_player_manager_->ReleaseMediaResources(); |
| 194 #endif |
| 195 WebKit::setIDBFactory(webkit_platform_support_->idbFactory()); |
| 196 } |
| 197 |
188 TestWebKitPlatformSupport* webkit_platform_support() const { | 198 TestWebKitPlatformSupport* webkit_platform_support() const { |
189 return webkit_platform_support_.get(); | 199 return webkit_platform_support_.get(); |
190 } | 200 } |
191 | 201 |
192 #if defined(OS_WIN) || defined(OS_MACOSX) | 202 #if defined(OS_WIN) || defined(OS_MACOSX) |
193 void set_theme_engine(WebKit::WebThemeEngine* engine) { | 203 void set_theme_engine(WebKit::WebThemeEngine* engine) { |
194 DCHECK(webkit_platform_support_ != 0); | 204 DCHECK(webkit_platform_support_ != 0); |
195 webkit_platform_support_->SetThemeEngine(engine); | 205 webkit_platform_support_->SetThemeEngine(engine); |
196 } | 206 } |
197 | 207 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 BeforeShutdown(); | 377 BeforeShutdown(); |
368 if (RunningOnValgrind()) | 378 if (RunningOnValgrind()) |
369 WebKit::WebCache::clear(); | 379 WebKit::WebCache::clear(); |
370 WebKit::shutdown(); | 380 WebKit::shutdown(); |
371 delete test_environment; | 381 delete test_environment; |
372 test_environment = NULL; | 382 test_environment = NULL; |
373 AfterShutdown(); | 383 AfterShutdown(); |
374 logging::CloseLogFile(); | 384 logging::CloseLogFile(); |
375 } | 385 } |
376 | 386 |
| 387 void ResetTestEnvironment() { |
| 388 test_environment->Reset(); |
| 389 } |
| 390 |
377 WebKit::WebKitPlatformSupport* GetWebKitPlatformSupport() { | 391 WebKit::WebKitPlatformSupport* GetWebKitPlatformSupport() { |
378 DCHECK(test_environment); | 392 DCHECK(test_environment); |
379 return test_environment->webkit_platform_support(); | 393 return test_environment->webkit_platform_support(); |
380 } | 394 } |
381 | 395 |
382 WebPlugin* CreateWebPlugin(WebFrame* frame, | 396 WebPlugin* CreateWebPlugin(WebFrame* frame, |
383 const WebPluginParams& params) { | 397 const WebPluginParams& params) { |
384 const bool kAllowWildcard = true; | 398 const bool kAllowWildcard = true; |
385 std::vector<webkit::WebPluginInfo> plugins; | 399 std::vector<webkit::WebPluginInfo> plugins; |
386 std::vector<std::string> mime_types; | 400 std::vector<std::string> mime_types; |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 // Logging | 877 // Logging |
864 void EnableWebCoreLogChannels(const std::string& channels) { | 878 void EnableWebCoreLogChannels(const std::string& channels) { |
865 webkit_glue::EnableWebCoreLogChannels(channels); | 879 webkit_glue::EnableWebCoreLogChannels(channels); |
866 } | 880 } |
867 | 881 |
868 void SetGamepadData(const WebKit::WebGamepads& pads) { | 882 void SetGamepadData(const WebKit::WebGamepads& pads) { |
869 test_environment->webkit_platform_support()->setGamepadData(pads); | 883 test_environment->webkit_platform_support()->setGamepadData(pads); |
870 } | 884 } |
871 | 885 |
872 } // namespace webkit_support | 886 } // namespace webkit_support |
OLD | NEW |