Commit 3d75e88a authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

Backport some tests in /content/public/test to SingleThreadTaskEnvironment

These tests were previously migrated from single-threaded MessageLoop to
a multi-threaded TaskEnvironment (then named ScopedTaskEnvironment) as
part of crbug.com/891670.

//base OWNERS decided in retrospect that it was better to keep a
single-threaded option for TaskEnvironment and introduced
SingleThreadTaskEnvironment. This CL retrofits that decision for
/content/public/test.

This CL is a no-op if it passes CQ.

This CL was uploaded by git cl split.

Edit: Revert changes to RenderViewTest and clarify comments in
      RenderViewHostTestEnabler in terms of "TaskEnvironment", not
      "MessageLoop".

R=tommi@chromium.org

Bug: 891670
Change-Id: I019f7a9f8c7b07e922feffef1e271a8d2e35e291
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787066
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: default avatarTommi <tommi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694585}
parent 74289685
...@@ -111,12 +111,14 @@ RenderViewHostTestEnabler::RenderViewHostTestEnabler() ...@@ -111,12 +111,14 @@ RenderViewHostTestEnabler::RenderViewHostTestEnabler()
rvh_factory_(new TestRenderViewHostFactory(rph_factory_.get())), rvh_factory_(new TestRenderViewHostFactory(rph_factory_.get())),
rfh_factory_(new TestRenderFrameHostFactory()), rfh_factory_(new TestRenderFrameHostFactory()),
rwhi_factory_(new TestRenderWidgetHostFactory()) { rwhi_factory_(new TestRenderWidgetHostFactory()) {
// A MessageLoop is needed for Mojo bindings to graphics services. Some // A TaskEnvironment is needed on the main thread for Mojo bindings to
// tests have their own, so this only creates one when none exists. This // graphics services. Some tests have their own, so this only creates one
// means tests must ensure any MessageLoop they make is created before // (single-threaded) when none exists. This means tests must ensure any
// the RenderViewHostTestEnabler. // TaskEnvironment they make is created before the RenderViewHostTestEnabler.
if (!base::MessageLoopCurrent::Get()) if (!base::MessageLoopCurrent::Get()) {
task_environment_ = std::make_unique<base::test::TaskEnvironment>(); task_environment_ =
std::make_unique<base::test::SingleThreadTaskEnvironment>();
}
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
ImageTransportFactory::SetFactory( ImageTransportFactory::SetFactory(
std::make_unique<TestImageTransportFactory>()); std::make_unique<TestImageTransportFactory>());
......
...@@ -154,7 +154,7 @@ class RenderViewHostTestEnabler { ...@@ -154,7 +154,7 @@ class RenderViewHostTestEnabler {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
std::unique_ptr<display::Screen> screen_; std::unique_ptr<display::Screen> screen_;
#endif #endif
std::unique_ptr<base::test::TaskEnvironment> task_environment_; std::unique_ptr<base::test::SingleThreadTaskEnvironment> task_environment_;
std::unique_ptr<MockRenderProcessHostFactory> rph_factory_; std::unique_ptr<MockRenderProcessHostFactory> rph_factory_;
std::unique_ptr<TestRenderViewHostFactory> rvh_factory_; std::unique_ptr<TestRenderViewHostFactory> rvh_factory_;
std::unique_ptr<TestRenderFrameHostFactory> rfh_factory_; std::unique_ptr<TestRenderFrameHostFactory> rfh_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment