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/test_webkit_platform_support.h" | 5 #include "webkit/support/test_webkit_platform_support.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/metrics/stats_counters.h" | 10 #include "base/metrics/stats_counters.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "cc/context_provider.h" |
14 #include "cc/thread_impl.h" | 15 #include "cc/thread_impl.h" |
15 #include "media/base/media.h" | 16 #include "media/base/media.h" |
16 #include "net/cookies/cookie_monster.h" | 17 #include "net/cookies/cookie_monster.h" |
17 #include "net/http/http_cache.h" | 18 #include "net/http/http_cache.h" |
18 #include "net/test/test_server.h" | 19 #include "net/test/test_server.h" |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebAudioDevice.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebAudioDevice.h" |
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" | 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebData.h" |
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h" |
22 #include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h" | 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebGamepads.h" |
23 #include "third_party/WebKit/Source/Platform/chromium/public/WebStorageArea.h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebStorageArea.h" |
24 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
25 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" |
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabase.h" |
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" |
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h
" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispat
cher.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageEventDispat
cher.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" |
33 #include "third_party/hyphen/hyphen.h" | 34 #include "third_party/hyphen/hyphen.h" |
34 #include "v8/include/v8.h" | 35 #include "v8/include/v8.h" |
35 #include "webkit/appcache/web_application_cache_host_impl.h" | 36 #include "webkit/appcache/web_application_cache_host_impl.h" |
36 #include "webkit/compositor_bindings/web_compositor_support_impl.h" | 37 #include "webkit/compositor_bindings/web_compositor_support_impl.h" |
37 #include "webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h" | 38 #include "webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h" |
38 #include "webkit/database/vfs_backend.h" | 39 #include "webkit/database/vfs_backend.h" |
39 #include "webkit/glue/simple_webmimeregistry_impl.h" | 40 #include "webkit/glue/simple_webmimeregistry_impl.h" |
40 #include "webkit/glue/webclipboard_impl.h" | 41 #include "webkit/glue/webclipboard_impl.h" |
41 #include "webkit/glue/webkit_glue.h" | 42 #include "webkit/glue/webkit_glue.h" |
42 #include "webkit/glue/webkitplatformsupport_impl.h" | 43 #include "webkit/glue/webkitplatformsupport_impl.h" |
| 44 #include "webkit/gpu/test_context_provider_factory.h" |
43 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | 45 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
44 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" | 46 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
45 #include "webkit/plugins/npapi/plugin_list.h" | 47 #include "webkit/plugins/npapi/plugin_list.h" |
46 #include "webkit/support/gc_extension.h" | 48 #include "webkit/support/gc_extension.h" |
47 #include "webkit/support/simple_database_system.h" | 49 #include "webkit/support/simple_database_system.h" |
48 #include "webkit/support/test_webmessageportchannel.h" | 50 #include "webkit/support/test_webmessageportchannel.h" |
49 #include "webkit/support/web_audio_device_mock.h" | 51 #include "webkit/support/web_audio_device_mock.h" |
50 #include "webkit/support/web_gesture_curve_mock.h" | 52 #include "webkit/support/web_gesture_curve_mock.h" |
51 #include "webkit/support/webkit_support.h" | 53 #include "webkit/support/webkit_support.h" |
52 #include "webkit/support/weburl_loader_mock_factory.h" | 54 #include "webkit/support/weburl_loader_mock_factory.h" |
(...skipping 13 matching lines...) Expand all Loading... |
66 #include "base/mac/mac_util.h" | 68 #include "base/mac/mac_util.h" |
67 #endif | 69 #endif |
68 | 70 |
69 using WebKit::WebLayerTreeViewImplForTesting; | 71 using WebKit::WebLayerTreeViewImplForTesting; |
70 using WebKit::WebScriptController; | 72 using WebKit::WebScriptController; |
71 | 73 |
72 TestWebKitPlatformSupport::TestWebKitPlatformSupport(bool unit_test_mode, | 74 TestWebKitPlatformSupport::TestWebKitPlatformSupport(bool unit_test_mode, |
73 WebKit::Platform* shadow_platform_delegate) | 75 WebKit::Platform* shadow_platform_delegate) |
74 : unit_test_mode_(unit_test_mode), | 76 : unit_test_mode_(unit_test_mode), |
75 shadow_platform_delegate_(shadow_platform_delegate), | 77 shadow_platform_delegate_(shadow_platform_delegate), |
76 hyphen_dictionary_(NULL) { | 78 hyphen_dictionary_(NULL), |
| 79 context_provider_factory_(NULL) { |
77 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); | 80 v8::V8::SetCounterFunction(base::StatsTable::FindLocation); |
78 | 81 |
79 WebKit::initialize(this); | 82 WebKit::initialize(this); |
80 WebKit::setLayoutTestMode(true); | 83 WebKit::setLayoutTestMode(true); |
81 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( | 84 WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( |
82 WebKit::WebString::fromUTF8("test-shell-resource")); | 85 WebKit::WebString::fromUTF8("test-shell-resource")); |
83 WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( | 86 WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( |
84 WebKit::WebString::fromUTF8("test-shell-resource")); | 87 WebKit::WebString::fromUTF8("test-shell-resource")); |
85 WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( | 88 WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated( |
86 WebKit::WebString::fromUTF8("test-shell-resource")); | 89 WebKit::WebString::fromUTF8("test-shell-resource")); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 153 |
151 // Test shell always exposes the GC. | 154 // Test shell always exposes the GC. |
152 webkit_glue::SetJavaScriptFlags(" --expose-gc"); | 155 webkit_glue::SetJavaScriptFlags(" --expose-gc"); |
153 // Expose GCController to JavaScript. | 156 // Expose GCController to JavaScript. |
154 WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); | 157 WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); |
155 } | 158 } |
156 | 159 |
157 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { | 160 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { |
158 if (hyphen_dictionary_) | 161 if (hyphen_dictionary_) |
159 hnj_hyphen_free(hyphen_dictionary_); | 162 hnj_hyphen_free(hyphen_dictionary_); |
| 163 if (context_provider_factory_) |
| 164 webkit::gpu::TestContextProviderFactory::DestroyInstance(); |
160 } | 165 } |
161 | 166 |
162 WebKit::WebMimeRegistry* TestWebKitPlatformSupport::mimeRegistry() { | 167 WebKit::WebMimeRegistry* TestWebKitPlatformSupport::mimeRegistry() { |
163 return &mime_registry_; | 168 return &mime_registry_; |
164 } | 169 } |
165 | 170 |
166 WebKit::WebClipboard* TestWebKitPlatformSupport::clipboard() { | 171 WebKit::WebClipboard* TestWebKitPlatformSupport::clipboard() { |
167 // Mock out clipboard calls so that tests don't mess | 172 // Mock out clipboard calls so that tests don't mess |
168 // with each other's copies/pastes when running in parallel. | 173 // with each other's copies/pastes when running in parallel. |
169 return &mock_clipboard_; | 174 return &mock_clipboard_; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl()); | 375 webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl()); |
371 if (!context->Initialize(attributes, NULL)) | 376 if (!context->Initialize(attributes, NULL)) |
372 return NULL; | 377 return NULL; |
373 return context.release(); | 378 return context.release(); |
374 } | 379 } |
375 } | 380 } |
376 NOTREACHED(); | 381 NOTREACHED(); |
377 return NULL; | 382 return NULL; |
378 } | 383 } |
379 | 384 |
| 385 WebKit::WebGraphicsContext3D* |
| 386 TestWebKitPlatformSupport::sharedOffscreenGraphicsContext3D() { |
| 387 if (!context_provider_factory_) { |
| 388 context_provider_factory_ = |
| 389 webkit::gpu::TestContextProviderFactory::GetInstance(); |
| 390 } |
| 391 |
| 392 main_thread_contexts_ = |
| 393 context_provider_factory_->OffscreenContextProviderForMainThread(); |
| 394 if (!main_thread_contexts_->InitializeOnMainThread()) |
| 395 return NULL; |
| 396 if (!main_thread_contexts_->BindToCurrentThread()) |
| 397 return NULL; |
| 398 return main_thread_contexts_->Context3d(); |
| 399 } |
| 400 |
| 401 GrContext* TestWebKitPlatformSupport::sharedOffscreenGrContext() { |
| 402 if (!main_thread_contexts_) |
| 403 return NULL; |
| 404 return main_thread_contexts_->GrContext(); |
| 405 } |
| 406 |
380 bool TestWebKitPlatformSupport::canAccelerate2dCanvas() { | 407 bool TestWebKitPlatformSupport::canAccelerate2dCanvas() { |
381 // We supply an OS-MESA based context for accelarated 2d | 408 // We supply an OS-MESA based context for accelarated 2d |
382 // canvas, which should always work. | 409 // canvas, which should always work. |
383 return true; | 410 return true; |
384 } | 411 } |
385 | 412 |
386 double TestWebKitPlatformSupport::audioHardwareSampleRate() { | 413 double TestWebKitPlatformSupport::audioHardwareSampleRate() { |
387 return 44100.0; | 414 return 44100.0; |
388 } | 415 } |
389 | 416 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 return view.release(); | 632 return view.release(); |
606 } | 633 } |
607 | 634 |
608 WebKit::WebLayerTreeView* | 635 WebKit::WebLayerTreeView* |
609 TestWebKitPlatformSupport::createLayerTreeViewForTesting( | 636 TestWebKitPlatformSupport::createLayerTreeViewForTesting( |
610 TestViewType type) { | 637 TestViewType type) { |
611 DCHECK_EQ(TestViewTypeUnitTest, type); | 638 DCHECK_EQ(TestViewTypeUnitTest, type); |
612 return createLayerTreeViewForTesting(); | 639 return createLayerTreeViewForTesting(); |
613 } | 640 } |
614 | 641 |
OLD | NEW |