diff --git a/components/cronet/native/test/buffer_test.cc b/components/cronet/native/test/buffer_test.cc index 1a95821e32de31..a92129cef65f0a 100644 --- a/components/cronet/native/test/buffer_test.cc +++ b/components/cronet/native/test/buffer_test.cc @@ -8,8 +8,8 @@ #include "base/logging.h" #include "base/macros.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/test/scoped_task_environment.h" #include "components/cronet/native/test/test_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,8 +25,10 @@ class BufferTest : public ::testing::Test { Cronet_BufferPtr buffer); bool on_destroy_called() const { return on_destroy_called_; } - // Provide a message loop for use by TestExecutor instances. - base::MessageLoop message_loop_; + // Provide a task environment for use by TestExecutor instances. Do not + // initialize the ThreadPool as this is done by the Cronet_Engine + base::test::ScopedTaskEnvironment scoped_task_environment_{ + base::test::ScopedTaskEnvironment::ThreadingMode::MAIN_THREAD_ONLY}; private: void set_on_destroy_called(bool value) { on_destroy_called_ = value; } diff --git a/components/cronet/native/test/executors_test.cc b/components/cronet/native/test/executors_test.cc index 76bf9a2747aa81..ab92dd76418ee9 100644 --- a/components/cronet/native/test/executors_test.cc +++ b/components/cronet/native/test/executors_test.cc @@ -6,8 +6,8 @@ #include "base/logging.h" #include "base/macros.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" +#include "base/test/scoped_task_environment.h" #include "components/cronet/native/test/test_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -22,8 +22,10 @@ class ExecutorsTest : public ::testing::Test { static void TestRunnable_Run(Cronet_RunnablePtr self); bool runnable_called() const { return runnable_called_; } - // Provide a message loop for use by TestExecutor instances. - base::MessageLoop message_loop_; + // Provide a task environment for use by TestExecutor instances. Do not + // initialize the ThreadPool as this is done by the Cronet_Engine + base::test::ScopedTaskEnvironment scoped_task_environment_{ + base::test::ScopedTaskEnvironment::ThreadingMode::MAIN_THREAD_ONLY}; private: void set_runnable_called(bool value) { runnable_called_ = value; } diff --git a/components/cronet/native/test/url_request_test.cc b/components/cronet/native/test/url_request_test.cc index 18241462b3fae6..f74bc0ab7e7342 100644 --- a/components/cronet/native/test/url_request_test.cc +++ b/components/cronet/native/test/url_request_test.cc @@ -10,9 +10,9 @@ #include "base/files/scoped_temp_dir.h" #include "base/logging.h" #include "base/macros.h" -#include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/synchronization/waitable_event.h" +#include "base/test/scoped_task_environment.h" #include "components/cronet/native/test/test_request_finished_info_listener.h" #include "components/cronet/native/test/test_upload_data_provider.h" #include "components/cronet/native/test/test_url_request_callback.h" @@ -484,8 +484,10 @@ class UrlRequestTest : public ::testing::TestWithParam< bool expect_error); protected: - // Provide a message loop for use by TestExecutor instances. - base::MessageLoop message_loop_; + // Provide a task environment for use by TestExecutor instances. Do not + // initialize the ThreadPool as this is done by the Cronet_Engine + base::test::ScopedTaskEnvironment scoped_task_environment_{ + base::test::ScopedTaskEnvironment::ThreadingMode::MAIN_THREAD_ONLY}; // Not owned, |request_finished_listener_| destroys itself when run. This // pointer is only needed to unregister the listener from the Engine in