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

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

Issue 1835553002: Control ES2015 'Tail call elimination' language feature via finch flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed redness by moving FeatureList initialization in tests up the call stack. Created 4 years, 8 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/files/file_path.h" 8 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/path_service.h" 12 #include "base/path_service.h"
12 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
15 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 base::mac::ScopedNSAutoreleasePool autorelease_pool; 93 base::mac::ScopedNSAutoreleasePool autorelease_pool;
93 #endif 94 #endif
94 95
95 url_loader_factory_.reset(new WebURLLoaderMockFactory()); 96 url_loader_factory_.reset(new WebURLLoaderMockFactory());
96 mock_clipboard_.reset(new MockWebClipboardImpl()); 97 mock_clipboard_.reset(new MockWebClipboardImpl());
97 98
98 #ifdef V8_USE_EXTERNAL_STARTUP_DATA 99 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
99 gin::V8Initializer::LoadV8Snapshot(); 100 gin::V8Initializer::LoadV8Snapshot();
100 gin::V8Initializer::LoadV8Natives(); 101 gin::V8Initializer::LoadV8Natives();
101 #endif 102 #endif
103 // Set up a FeatureList instance, so that code using that API will not hit
104 // an error that it's not set. Cleared by ClearInstanceForTesting() below.
105 base::FeatureList::SetInstance(make_scoped_ptr(new base::FeatureList));
102 106
103 scoped_refptr<base::SingleThreadTaskRunner> dummy_task_runner; 107 scoped_refptr<base::SingleThreadTaskRunner> dummy_task_runner;
104 scoped_ptr<base::ThreadTaskRunnerHandle> dummy_task_runner_handle; 108 scoped_ptr<base::ThreadTaskRunnerHandle> dummy_task_runner_handle;
105 if (!base::ThreadTaskRunnerHandle::IsSet()) { 109 if (!base::ThreadTaskRunnerHandle::IsSet()) {
106 // Dummy task runner is initialized here because the blink::initialize 110 // Dummy task runner is initialized here because the blink::initialize
107 // creates IsolateHolder which needs the current task runner handle. There 111 // creates IsolateHolder which needs the current task runner handle. There
108 // should be no task posted to this task runner. The message loop is not 112 // should be no task posted to this task runner. The message loop is not
109 // created before this initialization because some tests need specific kinds 113 // created before this initialization because some tests need specific kinds
110 // of message loops, and their types are not known upfront. Some tests also 114 // of message loops, and their types are not known upfront. Some tests also
111 // create their own thread bundles or message loops, and doing the same in 115 // create their own thread bundles or message loops, and doing the same in
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 std::string flags("--expose-gc"); 154 std::string flags("--expose-gc");
151 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); 155 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
152 } 156 }
153 157
154 TestBlinkWebUnitTestSupport::~TestBlinkWebUnitTestSupport() { 158 TestBlinkWebUnitTestSupport::~TestBlinkWebUnitTestSupport() {
155 url_loader_factory_.reset(); 159 url_loader_factory_.reset();
156 mock_clipboard_.reset(); 160 mock_clipboard_.reset();
157 if (renderer_scheduler_) 161 if (renderer_scheduler_)
158 renderer_scheduler_->Shutdown(); 162 renderer_scheduler_->Shutdown();
159 blink::shutdown(); 163 blink::shutdown();
164
165 // Clear the FeatureList that was registered above.
166 base::FeatureList::ClearInstanceForTesting();
160 } 167 }
161 168
162 blink::WebBlobRegistry* TestBlinkWebUnitTestSupport::blobRegistry() { 169 blink::WebBlobRegistry* TestBlinkWebUnitTestSupport::blobRegistry() {
163 return &blob_registry_; 170 return &blob_registry_;
164 } 171 }
165 172
166 blink::WebClipboard* TestBlinkWebUnitTestSupport::clipboard() { 173 blink::WebClipboard* TestBlinkWebUnitTestSupport::clipboard() {
167 // Mock out clipboard calls so that tests don't mess 174 // Mock out clipboard calls so that tests don't mess
168 // with each other's copies/pastes when running in parallel. 175 // with each other's copies/pastes when running in parallel.
169 return mock_clipboard_.get(); 176 return mock_clipboard_.get();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return BlinkPlatformImpl::currentThread(); 351 return BlinkPlatformImpl::currentThread();
345 } 352 }
346 353
347 void TestBlinkWebUnitTestSupport::getPluginList( 354 void TestBlinkWebUnitTestSupport::getPluginList(
348 bool refresh, blink::WebPluginListBuilder* builder) { 355 bool refresh, blink::WebPluginListBuilder* builder) {
349 builder->addPlugin("pdf", "pdf", "pdf-files"); 356 builder->addPlugin("pdf", "pdf", "pdf-files");
350 builder->addMediaTypeToLastPlugin("application/pdf", "pdf"); 357 builder->addMediaTypeToLastPlugin("application/pdf", "pdf");
351 } 358 }
352 359
353 } // namespace content 360 } // namespace content
OLDNEW
« base/test/test_suite.cc ('K') | « base/test/test_suite.cc ('k') | gin/isolate_holder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698