| 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/trees/layer_tree_settings.h" | 20 #include "cc/trees/layer_tree_settings.h" |
| 21 #include "components/scheduler/renderer/renderer_scheduler_impl.h" | |
| 22 #include "components/scheduler/renderer/webthread_impl_for_renderer_scheduler.h" | |
| 23 #include "components/scheduler/test/lazy_scheduler_message_loop_delegate_for_tes
ts.h" | |
| 24 #include "content/child/web_url_loader_impl.h" | 21 #include "content/child/web_url_loader_impl.h" |
| 25 #include "content/test/mock_webclipboard_impl.h" | 22 #include "content/test/mock_webclipboard_impl.h" |
| 26 #include "content/test/web_gesture_curve_mock.h" | 23 #include "content/test/web_gesture_curve_mock.h" |
| 27 #include "media/base/media.h" | 24 #include "media/base/media.h" |
| 28 #include "net/cookies/cookie_monster.h" | 25 #include "net/cookies/cookie_monster.h" |
| 29 #include "storage/browser/database/vfs_backend.h" | 26 #include "storage/browser/database/vfs_backend.h" |
| 30 #include "third_party/WebKit/public/platform/WebConnectionType.h" | 27 #include "third_party/WebKit/public/platform/WebConnectionType.h" |
| 31 #include "third_party/WebKit/public/platform/WebData.h" | 28 #include "third_party/WebKit/public/platform/WebData.h" |
| 32 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 29 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
| 33 #include "third_party/WebKit/public/platform/WebString.h" | 30 #include "third_party/WebKit/public/platform/WebString.h" |
| 34 #include "third_party/WebKit/public/platform/WebTaskRunner.h" | |
| 35 #include "third_party/WebKit/public/platform/WebThread.h" | 31 #include "third_party/WebKit/public/platform/WebThread.h" |
| 36 #include "third_party/WebKit/public/platform/WebURL.h" | 32 #include "third_party/WebKit/public/platform/WebURL.h" |
| 33 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
| 34 #include "third_party/WebKit/public/platform/scheduler/test/renderer_scheduler_t
est_support.h" |
| 37 #include "third_party/WebKit/public/web/WebKit.h" | 35 #include "third_party/WebKit/public/web/WebKit.h" |
| 38 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" | 36 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
| 39 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 37 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 40 #include "v8/include/v8.h" | 38 #include "v8/include/v8.h" |
| 41 | 39 |
| 42 #if defined(OS_MACOSX) | 40 #if defined(OS_MACOSX) |
| 43 #include "base/mac/foundation_util.h" | 41 #include "base/mac/foundation_util.h" |
| 44 #include "base/mac/scoped_nsautorelease_pool.h" | 42 #include "base/mac/scoped_nsautorelease_pool.h" |
| 45 #endif | 43 #endif |
| 46 | 44 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // creates IsolateHolder which needs the current task runner handle. There | 102 // creates IsolateHolder which needs the current task runner handle. There |
| 105 // should be no task posted to this task runner. The message loop is not | 103 // should be no task posted to this task runner. The message loop is not |
| 106 // created before this initialization because some tests need specific kinds | 104 // created before this initialization because some tests need specific kinds |
| 107 // of message loops, and their types are not known upfront. Some tests also | 105 // of message loops, and their types are not known upfront. Some tests also |
| 108 // create their own thread bundles or message loops, and doing the same in | 106 // create their own thread bundles or message loops, and doing the same in |
| 109 // TestBlinkWebUnitTestSupport would introduce a conflict. | 107 // TestBlinkWebUnitTestSupport would introduce a conflict. |
| 110 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); | 108 dummy_task_runner = make_scoped_refptr(new DummyTaskRunner()); |
| 111 dummy_task_runner_handle.reset( | 109 dummy_task_runner_handle.reset( |
| 112 new base::ThreadTaskRunnerHandle(dummy_task_runner)); | 110 new base::ThreadTaskRunnerHandle(dummy_task_runner)); |
| 113 } | 111 } |
| 114 renderer_scheduler_ = base::WrapUnique(new scheduler::RendererSchedulerImpl( | 112 renderer_scheduler_ = blink::scheduler::CreateRendererSchedulerForTests(); |
| 115 scheduler::LazySchedulerMessageLoopDelegateForTests::Create())); | |
| 116 web_thread_ = renderer_scheduler_->CreateMainThread(); | 113 web_thread_ = renderer_scheduler_->CreateMainThread(); |
| 117 | 114 |
| 118 // 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 |
| 119 // an error that it's not set. Cleared by ClearInstanceForTesting() below. | 116 // an error that it's not set. Cleared by ClearInstanceForTesting() below. |
| 120 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList)); | 117 base::FeatureList::SetInstance(base::WrapUnique(new base::FeatureList)); |
| 121 | 118 |
| 122 blink::initialize(this); | 119 blink::initialize(this); |
| 123 blink::setLayoutTestMode(true); | 120 blink::setLayoutTestMode(true); |
| 124 blink::WebRuntimeFeatures::enableDatabase(true); | 121 blink::WebRuntimeFeatures::enableDatabase(true); |
| 125 blink::WebRuntimeFeatures::enableNotifications(true); | 122 blink::WebRuntimeFeatures::enableNotifications(true); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 NOTREACHED() << | 177 NOTREACHED() << |
| 181 "IndexedDB cannot be tested with in-process harnesses."; | 178 "IndexedDB cannot be tested with in-process harnesses."; |
| 182 return NULL; | 179 return NULL; |
| 183 } | 180 } |
| 184 | 181 |
| 185 blink::WebMimeRegistry* TestBlinkWebUnitTestSupport::mimeRegistry() { | 182 blink::WebMimeRegistry* TestBlinkWebUnitTestSupport::mimeRegistry() { |
| 186 return &mime_registry_; | 183 return &mime_registry_; |
| 187 } | 184 } |
| 188 | 185 |
| 189 blink::WebURLLoader* TestBlinkWebUnitTestSupport::createURLLoader() { | 186 blink::WebURLLoader* TestBlinkWebUnitTestSupport::createURLLoader() { |
| 190 blink::WebThread* currentThread = Platform::current()->currentThread(); | |
| 191 // This loader should be used only for process-local resources such as | 187 // This loader should be used only for process-local resources such as |
| 192 // data URLs. | 188 // data URLs. |
| 193 blink::WebURLLoader* default_loader = new WebURLLoaderImpl( | 189 blink::WebURLLoader* default_loader = new WebURLLoaderImpl(nullptr); |
| 194 nullptr, currentThread->getWebTaskRunner()->clone()); | |
| 195 return url_loader_factory_->createURLLoader(default_loader); | 190 return url_loader_factory_->createURLLoader(default_loader); |
| 196 } | 191 } |
| 197 | 192 |
| 198 blink::WebString TestBlinkWebUnitTestSupport::userAgent() { | 193 blink::WebString TestBlinkWebUnitTestSupport::userAgent() { |
| 199 return blink::WebString::fromUTF8("test_runner/0.0.0.0"); | 194 return blink::WebString::fromUTF8("test_runner/0.0.0.0"); |
| 200 } | 195 } |
| 201 | 196 |
| 202 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( | 197 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( |
| 203 blink::WebLocalizedString::Name name) { | 198 blink::WebLocalizedString::Name name) { |
| 204 // Returns placeholder strings to check if they are correctly localized. | 199 // Returns placeholder strings to check if they are correctly localized. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return BlinkPlatformImpl::currentThread(); | 286 return BlinkPlatformImpl::currentThread(); |
| 292 } | 287 } |
| 293 | 288 |
| 294 void TestBlinkWebUnitTestSupport::getPluginList( | 289 void TestBlinkWebUnitTestSupport::getPluginList( |
| 295 bool refresh, blink::WebPluginListBuilder* builder) { | 290 bool refresh, blink::WebPluginListBuilder* builder) { |
| 296 builder->addPlugin("pdf", "pdf", "pdf-files"); | 291 builder->addPlugin("pdf", "pdf", "pdf-files"); |
| 297 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); | 292 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); |
| 298 } | 293 } |
| 299 | 294 |
| 300 } // namespace content | 295 } // namespace content |
| OLD | NEW |