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/test_blink_web_unit_test_support.h" | 5 #include "content/test/test_blink_web_unit_test_support.h" |
6 | 6 |
7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "cc/blink/web_layer_impl.h" | 19 #include "cc/blink/web_layer_impl.h" |
| 20 #include "cc/test/test_shared_bitmap_manager.h" |
20 #include "cc/trees/layer_tree_settings.h" | 21 #include "cc/trees/layer_tree_settings.h" |
21 #include "content/child/web_url_loader_impl.h" | 22 #include "content/child/web_url_loader_impl.h" |
22 #include "content/test/mock_webclipboard_impl.h" | 23 #include "content/test/mock_webclipboard_impl.h" |
23 #include "content/test/web_gesture_curve_mock.h" | 24 #include "content/test/web_gesture_curve_mock.h" |
24 #include "media/base/media.h" | 25 #include "media/base/media.h" |
25 #include "net/cookies/cookie_monster.h" | 26 #include "net/cookies/cookie_monster.h" |
26 #include "storage/browser/database/vfs_backend.h" | 27 #include "storage/browser/database/vfs_backend.h" |
27 #include "third_party/WebKit/public/platform/WebConnectionType.h" | 28 #include "third_party/WebKit/public/platform/WebConnectionType.h" |
28 #include "third_party/WebKit/public/platform/WebData.h" | 29 #include "third_party/WebKit/public/platform/WebData.h" |
29 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 30 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // created before this initialization because some tests need specific kinds | 111 // created before this initialization because some tests need specific kinds |
111 // of message loops, and their types are not known upfront. Some tests also | 112 // of message loops, and their types are not known upfront. Some tests also |
112 // create their own thread bundles or message loops, and doing the same in | 113 // create their own thread bundles or message loops, and doing the same in |
113 // TestBlinkWebUnitTestSupport would introduce a conflict. | 114 // TestBlinkWebUnitTestSupport would introduce a conflict. |
114 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); | 115 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); |
115 dummy_task_runner_handle.reset( | 116 dummy_task_runner_handle.reset( |
116 new base::ThreadTaskRunnerHandle(dummy_task_runner)); | 117 new base::ThreadTaskRunnerHandle(dummy_task_runner)); |
117 } | 118 } |
118 renderer_scheduler_ = blink::scheduler::CreateRendererSchedulerForTests(); | 119 renderer_scheduler_ = blink::scheduler::CreateRendererSchedulerForTests(); |
119 web_thread_ = renderer_scheduler_->CreateMainThread(); | 120 web_thread_ = renderer_scheduler_->CreateMainThread(); |
| 121 shared_bitmap_manager_.reset(new cc::TestSharedBitmapManager); |
120 | 122 |
121 // Set up a FeatureList instance, so that code using that API will not hit a | 123 // Set up a FeatureList instance, so that code using that API will not hit a |
122 // an error that it's not set. Cleared by ClearInstanceForTesting() below. | 124 // an error that it's not set. Cleared by ClearInstanceForTesting() below. |
123 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList)); | 125 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList)); |
124 | 126 |
125 blink::initialize(this); | 127 blink::initialize(this); |
126 blink::setLayoutTestMode(true); | 128 blink::setLayoutTestMode(true); |
127 blink::WebRuntimeFeatures::enableDatabase(true); | 129 blink::WebRuntimeFeatures::enableDatabase(true); |
128 blink::WebRuntimeFeatures::enableNotifications(true); | 130 blink::WebRuntimeFeatures::enableNotifications(true); |
129 blink::WebRuntimeFeatures::enableTouch(true); | 131 blink::WebRuntimeFeatures::enableTouch(true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // This loader should be used only for process-local resources such as | 194 // This loader should be used only for process-local resources such as |
193 // data URLs. | 195 // data URLs. |
194 blink::WebURLLoader* default_loader = new WebURLLoaderImpl(nullptr, nullptr); | 196 blink::WebURLLoader* default_loader = new WebURLLoaderImpl(nullptr, nullptr); |
195 return url_loader_factory_->createURLLoader(default_loader); | 197 return url_loader_factory_->createURLLoader(default_loader); |
196 } | 198 } |
197 | 199 |
198 blink::WebString TestBlinkWebUnitTestSupport::userAgent() { | 200 blink::WebString TestBlinkWebUnitTestSupport::userAgent() { |
199 return blink::WebString::fromUTF8("test_runner/0.0.0.0"); | 201 return blink::WebString::fromUTF8("test_runner/0.0.0.0"); |
200 } | 202 } |
201 | 203 |
| 204 std::unique_ptr<cc::SharedBitmap> |
| 205 TestBlinkWebUnitTestSupport::allocateSharedBitmap( |
| 206 const blink::WebSize& size) { |
| 207 return shared_bitmap_manager_ |
| 208 ->AllocateSharedBitmap(gfx::Size(size.width, size.height)); |
| 209 } |
| 210 |
202 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( | 211 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( |
203 blink::WebLocalizedString::Name name) { | 212 blink::WebLocalizedString::Name name) { |
204 // Returns placeholder strings to check if they are correctly localized. | 213 // Returns placeholder strings to check if they are correctly localized. |
205 switch (name) { | 214 switch (name) { |
206 case blink::WebLocalizedString::OtherDateLabel: | 215 case blink::WebLocalizedString::OtherDateLabel: |
207 return base::ASCIIToUTF16("<<OtherDateLabel>>"); | 216 return base::ASCIIToUTF16("<<OtherDateLabel>>"); |
208 case blink::WebLocalizedString::OtherMonthLabel: | 217 case blink::WebLocalizedString::OtherMonthLabel: |
209 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); | 218 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); |
210 case blink::WebLocalizedString::OtherTimeLabel: | 219 case blink::WebLocalizedString::OtherTimeLabel: |
211 return base::ASCIIToUTF16("<<OtherTimeLabel>>"); | 220 return base::ASCIIToUTF16("<<OtherTimeLabel>>"); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 blink::WebRTCCertificateGenerator* | 342 blink::WebRTCCertificateGenerator* |
334 TestBlinkWebUnitTestSupport::createRTCCertificateGenerator() { | 343 TestBlinkWebUnitTestSupport::createRTCCertificateGenerator() { |
335 #if defined(ENABLE_WEBRTC) | 344 #if defined(ENABLE_WEBRTC) |
336 return new TestWebRTCCertificateGenerator(); | 345 return new TestWebRTCCertificateGenerator(); |
337 #else | 346 #else |
338 return nullptr; | 347 return nullptr; |
339 #endif | 348 #endif |
340 } | 349 } |
341 | 350 |
342 } // namespace content | 351 } // namespace content |
OLD | NEW |