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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // created before this initialization because some tests need specific kinds | 105 // created before this initialization because some tests need specific kinds |
105 // of message loops, and their types are not known upfront. Some tests also | 106 // of message loops, and their types are not known upfront. Some tests also |
106 // create their own thread bundles or message loops, and doing the same in | 107 // create their own thread bundles or message loops, and doing the same in |
107 // TestBlinkWebUnitTestSupport would introduce a conflict. | 108 // TestBlinkWebUnitTestSupport would introduce a conflict. |
108 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); | 109 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); |
109 dummy_task_runner_handle.reset( | 110 dummy_task_runner_handle.reset( |
110 new base::ThreadTaskRunnerHandle(dummy_task_runner)); | 111 new base::ThreadTaskRunnerHandle(dummy_task_runner)); |
111 } | 112 } |
112 renderer_scheduler_ = blink::scheduler::CreateRendererSchedulerForTests(); | 113 renderer_scheduler_ = blink::scheduler::CreateRendererSchedulerForTests(); |
113 web_thread_ = renderer_scheduler_->CreateMainThread(); | 114 web_thread_ = renderer_scheduler_->CreateMainThread(); |
| 115 shared_bitmap_manager_.reset(new cc::TestSharedBitmapManager); |
114 | 116 |
115 // Set up a FeatureList instance, so that code using that API will not hit a | 117 // Set up a FeatureList instance, so that code using that API will not hit a |
116 // an error that it's not set. Cleared by ClearInstanceForTesting() below. | 118 // an error that it's not set. Cleared by ClearInstanceForTesting() below. |
117 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList)); | 119 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList)); |
118 | 120 |
119 blink::initialize(this); | 121 blink::initialize(this); |
120 blink::setLayoutTestMode(true); | 122 blink::setLayoutTestMode(true); |
121 blink::WebRuntimeFeatures::enableDatabase(true); | 123 blink::WebRuntimeFeatures::enableDatabase(true); |
122 blink::WebRuntimeFeatures::enableNotifications(true); | 124 blink::WebRuntimeFeatures::enableNotifications(true); |
123 blink::WebRuntimeFeatures::enableTouch(true); | 125 blink::WebRuntimeFeatures::enableTouch(true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // This loader should be used only for process-local resources such as | 188 // This loader should be used only for process-local resources such as |
187 // data URLs. | 189 // data URLs. |
188 blink::WebURLLoader* default_loader = new WebURLLoaderImpl(nullptr, nullptr); | 190 blink::WebURLLoader* default_loader = new WebURLLoaderImpl(nullptr, nullptr); |
189 return url_loader_factory_->createURLLoader(default_loader); | 191 return url_loader_factory_->createURLLoader(default_loader); |
190 } | 192 } |
191 | 193 |
192 blink::WebString TestBlinkWebUnitTestSupport::userAgent() { | 194 blink::WebString TestBlinkWebUnitTestSupport::userAgent() { |
193 return blink::WebString::fromUTF8("test_runner/0.0.0.0"); | 195 return blink::WebString::fromUTF8("test_runner/0.0.0.0"); |
194 } | 196 } |
195 | 197 |
| 198 std::unique_ptr<cc::SharedBitmap> |
| 199 TestBlinkWebUnitTestSupport::allocateSharedBitmap( |
| 200 const blink::WebSize& size) { |
| 201 return shared_bitmap_manager_ |
| 202 ->AllocateSharedBitmap(gfx::Size(size.width, size.height)); |
| 203 } |
| 204 |
196 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( | 205 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( |
197 blink::WebLocalizedString::Name name) { | 206 blink::WebLocalizedString::Name name) { |
198 // Returns placeholder strings to check if they are correctly localized. | 207 // Returns placeholder strings to check if they are correctly localized. |
199 switch (name) { | 208 switch (name) { |
200 case blink::WebLocalizedString::OtherDateLabel: | 209 case blink::WebLocalizedString::OtherDateLabel: |
201 return base::ASCIIToUTF16("<<OtherDateLabel>>"); | 210 return base::ASCIIToUTF16("<<OtherDateLabel>>"); |
202 case blink::WebLocalizedString::OtherMonthLabel: | 211 case blink::WebLocalizedString::OtherMonthLabel: |
203 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); | 212 return base::ASCIIToUTF16("<<OtherMonthLabel>>"); |
204 case blink::WebLocalizedString::OtherTimeLabel: | 213 case blink::WebLocalizedString::OtherTimeLabel: |
205 return base::ASCIIToUTF16("<<OtherTimeLabel>>"); | 214 return base::ASCIIToUTF16("<<OtherTimeLabel>>"); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 296 |
288 void TestBlinkWebUnitTestSupport::getPluginList( | 297 void TestBlinkWebUnitTestSupport::getPluginList( |
289 bool refresh, | 298 bool refresh, |
290 const blink::WebSecurityOrigin& mainFrameOrigin, | 299 const blink::WebSecurityOrigin& mainFrameOrigin, |
291 blink::WebPluginListBuilder* builder) { | 300 blink::WebPluginListBuilder* builder) { |
292 builder->addPlugin("pdf", "pdf", "pdf-files"); | 301 builder->addPlugin("pdf", "pdf", "pdf-files"); |
293 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); | 302 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); |
294 } | 303 } |
295 | 304 |
296 } // namespace content | 305 } // namespace content |
OLD | NEW |