| 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/path_service.h" | 13 #include "base/path_service.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "cc/blink/web_layer_impl.h" | 19 #include "cc/blink/web_layer_impl.h" |
| 19 #include "cc/trees/layer_tree_settings.h" | 20 #include "cc/trees/layer_tree_settings.h" |
| 20 #include "components/scheduler/renderer/renderer_scheduler_impl.h" | 21 #include "components/scheduler/renderer/renderer_scheduler_impl.h" |
| 21 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" | 22 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 88 |
| 88 url_loader_factory_ = blink::WebURLLoaderMockFactory::create(); | 89 url_loader_factory_ = blink::WebURLLoaderMockFactory::create(); |
| 89 mock_clipboard_.reset(new MockWebClipboardImpl()); | 90 mock_clipboard_.reset(new MockWebClipboardImpl()); |
| 90 | 91 |
| 91 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 92 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 92 gin::V8Initializer::LoadV8Snapshot(); | 93 gin::V8Initializer::LoadV8Snapshot(); |
| 93 gin::V8Initializer::LoadV8Natives(); | 94 gin::V8Initializer::LoadV8Natives(); |
| 94 #endif | 95 #endif |
| 95 | 96 |
| 96 scoped_refptr<base::SingleThreadTaskRunner> dummy_task_runner; | 97 scoped_refptr<base::SingleThreadTaskRunner> dummy_task_runner; |
| 97 scoped_ptr<base::ThreadTaskRunnerHandle> dummy_task_runner_handle; | 98 std::unique_ptr<base::ThreadTaskRunnerHandle> dummy_task_runner_handle; |
| 98 if (!base::ThreadTaskRunnerHandle::IsSet()) { | 99 if (!base::ThreadTaskRunnerHandle::IsSet()) { |
| 99 // Dummy task runner is initialized here because the blink::initialize | 100 // Dummy task runner is initialized here because the blink::initialize |
| 100 // creates IsolateHolder which needs the current task runner handle. There | 101 // creates IsolateHolder which needs the current task runner handle. There |
| 101 // should be no task posted to this task runner. The message loop is not | 102 // should be no task posted to this task runner. The message loop is not |
| 102 // created before this initialization because some tests need specific kinds | 103 // created before this initialization because some tests need specific kinds |
| 103 // of message loops, and their types are not known upfront. Some tests also | 104 // of message loops, and their types are not known upfront. Some tests also |
| 104 // create their own thread bundles or message loops, and doing the same in | 105 // create their own thread bundles or message loops, and doing the same in |
| 105 // TestBlinkWebUnitTestSupport would introduce a conflict. | 106 // TestBlinkWebUnitTestSupport would introduce a conflict. |
| 106 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); | 107 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); |
| 107 dummy_task_runner_handle.reset( | 108 dummy_task_runner_handle.reset( |
| 108 new base::ThreadTaskRunnerHandle(dummy_task_runner)); | 109 new base::ThreadTaskRunnerHandle(dummy_task_runner)); |
| 109 } | 110 } |
| 110 renderer_scheduler_ = make_scoped_ptr(new scheduler::RendererSchedulerImpl( | 111 renderer_scheduler_ = base::WrapUnique(new scheduler::RendererSchedulerImpl( |
| 111 scheduler::LazySchedulerMessageLoopDelegateForTests::Create())); | 112 scheduler::LazySchedulerMessageLoopDelegateForTests::Create())); |
| 112 web_thread_ = renderer_scheduler_->CreateMainThread(); | 113 web_thread_ = renderer_scheduler_->CreateMainThread(); |
| 113 | 114 |
| 114 // Set up a FeatureList instance, so that code using that API will not hit a | 115 // Set up a FeatureList instance, so that code using that API will not hit a |
| 115 // an error that it's not set. Cleared by ClearInstanceForTesting() below. | 116 // an error that it's not set. Cleared by ClearInstanceForTesting() below. |
| 116 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList)); | 117 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList)); |
| 117 | 118 |
| 118 blink::initialize(this); | 119 blink::initialize(this); |
| 119 blink::setLayoutTestMode(true); | 120 blink::setLayoutTestMode(true); |
| 120 blink::WebRuntimeFeatures::enableApplicationCache(true); | 121 blink::WebRuntimeFeatures::enableApplicationCache(true); |
| 121 blink::WebRuntimeFeatures::enableDatabase(true); | 122 blink::WebRuntimeFeatures::enableDatabase(true); |
| 122 blink::WebRuntimeFeatures::enableNotifications(true); | 123 blink::WebRuntimeFeatures::enableNotifications(true); |
| 123 blink::WebRuntimeFeatures::enableTouch(true); | 124 blink::WebRuntimeFeatures::enableTouch(true); |
| 124 | 125 |
| 125 // Initialize NetworkStateNotifier. | 126 // Initialize NetworkStateNotifier. |
| 126 blink::WebNetworkStateNotifier::setWebConnection( | 127 blink::WebNetworkStateNotifier::setWebConnection( |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 return BlinkPlatformImpl::currentThread(); | 305 return BlinkPlatformImpl::currentThread(); |
| 305 } | 306 } |
| 306 | 307 |
| 307 void TestBlinkWebUnitTestSupport::getPluginList( | 308 void TestBlinkWebUnitTestSupport::getPluginList( |
| 308 bool refresh, blink::WebPluginListBuilder* builder) { | 309 bool refresh, blink::WebPluginListBuilder* builder) { |
| 309 builder->addPlugin("pdf", "pdf", "pdf-files"); | 310 builder->addPlugin("pdf", "pdf", "pdf-files"); |
| 310 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); | 311 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); |
| 311 } | 312 } |
| 312 | 313 |
| 313 } // namespace content | 314 } // namespace content |
| OLD | NEW |