Commit f8e76545 authored by Carlos Caballero's avatar Carlos Caballero Committed by Commit Bot

Use ScopedTaskEnvironment instead of MessageLoopForUI in /chrome

MessageLoopForUI will go away, eventually.

ScopedTaskEnvironment will per default start a ThreadPool, which should
be fine in most of the cases. If you believe your test needs to make sure
that no ThreadPool runs let me know and I will update the patch.

BUG=891670
This CL was uploaded by git cl split.

R=droger@chromium.org

Change-Id: Id81a7f75bf4fa64c4c7b4ca4d8830768ef6b2d27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715819
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Auto-Submit: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/master@{#682656}
parent 280ac36b
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_pump_type.h" #include "base/message_loop/message_pump_type.h"
#include "base/process/launch.h" #include "base/process/launch.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/test/scoped_task_environment.h"
#include "base/test/test_timeouts.h" #include "base/test/test_timeouts.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "chrome/common/mac/launchd.h" #include "chrome/common/mac/launchd.h"
...@@ -50,16 +50,17 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { ...@@ -50,16 +50,17 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
ASSERT_TRUE(MockLaunchd::MakeABundle(GetTempDirPath(), "Test", ASSERT_TRUE(MockLaunchd::MakeABundle(GetTempDirPath(), "Test",
&bundle_path_, &executable_path_)); &bundle_path_, &executable_path_));
mock_launchd_.reset(new MockLaunchd(executable_path_, loop_.task_runner(), mock_launchd_.reset(new MockLaunchd(
run_loop_.QuitClosure(), true)); executable_path_, scoped_task_environment_.GetMainThreadTaskRunner(),
run_loop_.QuitClosure(), true));
scoped_launchd_instance_.reset( scoped_launchd_instance_.reset(
new Launchd::ScopedInstance(mock_launchd_.get())); new Launchd::ScopedInstance(mock_launchd_.get()));
ASSERT_TRUE(service_process_state_.Initialize()); ASSERT_TRUE(service_process_state_.Initialize());
ASSERT_TRUE(service_process_state_.SignalReady( ASSERT_TRUE(service_process_state_.SignalReady(
io_thread_.task_runner().get(), base::Closure())); io_thread_.task_runner().get(), base::Closure()));
loop_.task_runner()->PostDelayedTask(FROM_HERE, scoped_task_environment_.GetMainThreadTaskRunner()->PostDelayedTask(
run_loop_.QuitWhenIdleClosure(), FROM_HERE, run_loop_.QuitWhenIdleClosure(),
TestTimeouts::action_max_timeout()); TestTimeouts::action_max_timeout());
} }
const MockLaunchd* mock_launchd() const { return mock_launchd_.get(); } const MockLaunchd* mock_launchd() const { return mock_launchd_.get(); }
...@@ -76,7 +77,8 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test { ...@@ -76,7 +77,8 @@ class ServiceProcessStateFileManipulationTest : public ::testing::Test {
private: private:
base::ScopedTempDir temp_dir_; base::ScopedTempDir temp_dir_;
base::MessageLoopForUI loop_; base::test::ScopedTaskEnvironment scoped_task_environment_{
base::test::ScopedTaskEnvironment::MainThreadType::UI};
base::RunLoop run_loop_; base::RunLoop run_loop_;
base::Thread io_thread_; base::Thread io_thread_;
base::FilePath executable_path_, bundle_path_; base::FilePath executable_path_, bundle_path_;
......
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