Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: content/test/test_blink_web_unit_test_support.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another GYP fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::enableApplicationCache(true); 121 blink::WebRuntimeFeatures::enableApplicationCache(true);
125 blink::WebRuntimeFeatures::enableDatabase(true); 122 blink::WebRuntimeFeatures::enableDatabase(true);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 NOTREACHED() << 178 NOTREACHED() <<
182 "IndexedDB cannot be tested with in-process harnesses."; 179 "IndexedDB cannot be tested with in-process harnesses.";
183 return NULL; 180 return NULL;
184 } 181 }
185 182
186 blink::WebMimeRegistry* TestBlinkWebUnitTestSupport::mimeRegistry() { 183 blink::WebMimeRegistry* TestBlinkWebUnitTestSupport::mimeRegistry() {
187 return &mime_registry_; 184 return &mime_registry_;
188 } 185 }
189 186
190 blink::WebURLLoader* TestBlinkWebUnitTestSupport::createURLLoader() { 187 blink::WebURLLoader* TestBlinkWebUnitTestSupport::createURLLoader() {
191 blink::WebThread* currentThread = Platform::current()->currentThread();
192 // 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
193 // data URLs. 189 // data URLs.
194 blink::WebURLLoader* default_loader = new WebURLLoaderImpl( 190 blink::WebURLLoader* default_loader = new WebURLLoaderImpl(nullptr);
195 nullptr, base::WrapUnique(currentThread->getWebTaskRunner()->clone()));
196 return url_loader_factory_->createURLLoader(default_loader); 191 return url_loader_factory_->createURLLoader(default_loader);
197 } 192 }
198 193
199 blink::WebString TestBlinkWebUnitTestSupport::userAgent() { 194 blink::WebString TestBlinkWebUnitTestSupport::userAgent() {
200 return blink::WebString::fromUTF8("test_runner/0.0.0.0"); 195 return blink::WebString::fromUTF8("test_runner/0.0.0.0");
201 } 196 }
202 197
203 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString( 198 blink::WebString TestBlinkWebUnitTestSupport::queryLocalizedString(
204 blink::WebLocalizedString::Name name) { 199 blink::WebLocalizedString::Name name) {
205 // Returns placeholder strings to check if they are correctly localized. 200 // Returns placeholder strings to check if they are correctly localized.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return BlinkPlatformImpl::currentThread(); 287 return BlinkPlatformImpl::currentThread();
293 } 288 }
294 289
295 void TestBlinkWebUnitTestSupport::getPluginList( 290 void TestBlinkWebUnitTestSupport::getPluginList(
296 bool refresh, blink::WebPluginListBuilder* builder) { 291 bool refresh, blink::WebPluginListBuilder* builder) {
297 builder->addPlugin("pdf", "pdf", "pdf-files"); 292 builder->addPlugin("pdf", "pdf", "pdf-files");
298 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); 293 builder->addMediaTypeToLastPlugin("application/pdf", "pdf");
299 } 294 }
300 295
301 } // namespace content 296 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698