Commit 264b1464 authored by Carlos Caballero's avatar Carlos Caballero Committed by Commit Bot

Remove MessageLoop references in /gpu

MessageLoop is going away soon.

This CL was uploaded by git cl split.

R=zmo@chromium.org

Bug: 891670
Change-Id: Ie1657d67a62df040a9ee074cc83af4297fcd6fa1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1945810
Auto-Submit: Carlos Caballero <carlscab@google.com>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Carlos Caballero <carlscab@google.com>
Cr-Commit-Position: refs/heads/master@{#720859}
parent fbce1918
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/test/task_environment.h"
#include "gpu/ipc/service/gpu_watchdog_thread_v2.h" #include "gpu/ipc/service/gpu_watchdog_thread_v2.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_current.h" #include "base/message_loop/message_loop_current.h"
#include "base/power_monitor/power_monitor.h" #include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_source.h" #include "base/power_monitor/power_monitor_source.h"
...@@ -45,7 +45,7 @@ class GpuWatchdogTest : public testing::Test { ...@@ -45,7 +45,7 @@ class GpuWatchdogTest : public testing::Test {
protected: protected:
~GpuWatchdogTest() override = default; ~GpuWatchdogTest() override = default;
base::MessageLoop main_loop; base::test::SingleThreadTaskEnvironment task_environment_;
base::RunLoop run_loop; base::RunLoop run_loop;
std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread_; std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread_;
}; };
...@@ -174,23 +174,24 @@ TEST_F(GpuWatchdogTest, MAYBE_GpuInitializationAndRunningTasks) { ...@@ -174,23 +174,24 @@ TEST_F(GpuWatchdogTest, MAYBE_GpuInitializationAndRunningTasks) {
// Start running GPU tasks. Watchdog function WillProcessTask(), // Start running GPU tasks. Watchdog function WillProcessTask(),
// DidProcessTask() and ReportProgress() are tested. // DidProcessTask() and ReportProgress() are tested.
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&SimpleTask, base::TimeDelta::FromMilliseconds(500))); base::BindOnce(&SimpleTask, base::TimeDelta::FromMilliseconds(500)));
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&SimpleTask, base::TimeDelta::FromMilliseconds(500))); base::BindOnce(&SimpleTask, base::TimeDelta::FromMilliseconds(500)));
// This long task takes 3000 milliseconds to finish, longer than timeout. // This long task takes 3000 milliseconds to finish, longer than timeout.
// But it reports progress every 500 milliseconds // But it reports progress every 500 milliseconds
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&GpuWatchdogTest::LongTaskWithReportProgress, FROM_HERE, base::BindOnce(&GpuWatchdogTest::LongTaskWithReportProgress,
base::Unretained(this), base::Unretained(this),
kGpuWatchdogTimeoutForTesting + kGpuWatchdogTimeoutForTesting +
base::TimeDelta::FromMilliseconds(2000), base::TimeDelta::FromMilliseconds(2000),
base::TimeDelta::FromMilliseconds(500))); base::TimeDelta::FromMilliseconds(500)));
main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); task_environment_.GetMainThreadTaskRunner()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
// Everything should be fine. No GPU hang detected. // Everything should be fine. No GPU hang detected.
...@@ -205,7 +206,7 @@ TEST_F(GpuWatchdogTest, GpuRunningATaskHang) { ...@@ -205,7 +206,7 @@ TEST_F(GpuWatchdogTest, GpuRunningATaskHang) {
// Start running a GPU task. // Start running a GPU task.
#if defined(OS_WIN) #if defined(OS_WIN)
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 + base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 +
kGpuWatchdogTimeoutForTesting * kGpuWatchdogTimeoutForTesting *
...@@ -213,14 +214,15 @@ TEST_F(GpuWatchdogTest, GpuRunningATaskHang) { ...@@ -213,14 +214,15 @@ TEST_F(GpuWatchdogTest, GpuRunningATaskHang) {
kMaxWaitTimeForTesting + kMaxWaitTimeForTesting +
base::TimeDelta::FromMilliseconds(4000))); base::TimeDelta::FromMilliseconds(4000)));
#else #else
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 + base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 +
kMaxWaitTimeForTesting + kMaxWaitTimeForTesting +
base::TimeDelta::FromMilliseconds(4000))); base::TimeDelta::FromMilliseconds(4000)));
#endif #endif
main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); task_environment_.GetMainThreadTaskRunner()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
// This GPU task takes too long. A GPU hang should be detected. // This GPU task takes too long. A GPU hang should be detected.
...@@ -240,11 +242,12 @@ TEST_F(GpuWatchdogTest, ChromeInBackground) { ...@@ -240,11 +242,12 @@ TEST_F(GpuWatchdogTest, ChromeInBackground) {
watchdog_thread_->OnInitComplete(); watchdog_thread_->OnInitComplete();
// Run a task that takes longer (3000 milliseconds) than timeout. // Run a task that takes longer (3000 milliseconds) than timeout.
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 + base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 +
base::TimeDelta::FromMilliseconds(1000))); base::TimeDelta::FromMilliseconds(1000)));
main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); task_environment_.GetMainThreadTaskRunner()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
// The gpu might be slow when running in the background. This is ok. // The gpu might be slow when running in the background. This is ok.
...@@ -260,7 +263,7 @@ TEST_F(GpuWatchdogTest, GpuSwitchingToForegroundHang) { ...@@ -260,7 +263,7 @@ TEST_F(GpuWatchdogTest, GpuSwitchingToForegroundHang) {
// switches to the foreground and runs for 6000 milliseconds. This is longer // switches to the foreground and runs for 6000 milliseconds. This is longer
// than the first-time foreground watchdog timeout (2000 ms). // than the first-time foreground watchdog timeout (2000 ms).
#if defined(OS_WIN) #if defined(OS_WIN)
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&GpuWatchdogTest::LongTaskFromBackgroundToForeground, base::BindOnce(&GpuWatchdogTest::LongTaskFromBackgroundToForeground,
base::Unretained(this), base::Unretained(this),
...@@ -272,7 +275,7 @@ TEST_F(GpuWatchdogTest, GpuSwitchingToForegroundHang) { ...@@ -272,7 +275,7 @@ TEST_F(GpuWatchdogTest, GpuSwitchingToForegroundHang) {
/*time_to_switch_to_foreground*/ /*time_to_switch_to_foreground*/
base::TimeDelta::FromMilliseconds(200))); base::TimeDelta::FromMilliseconds(200)));
#else #else
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&GpuWatchdogTest::LongTaskFromBackgroundToForeground, base::BindOnce(&GpuWatchdogTest::LongTaskFromBackgroundToForeground,
base::Unretained(this), base::Unretained(this),
...@@ -283,7 +286,8 @@ TEST_F(GpuWatchdogTest, GpuSwitchingToForegroundHang) { ...@@ -283,7 +286,8 @@ TEST_F(GpuWatchdogTest, GpuSwitchingToForegroundHang) {
base::TimeDelta::FromMilliseconds(200))); base::TimeDelta::FromMilliseconds(200)));
#endif #endif
main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); task_environment_.GetMainThreadTaskRunner()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
// It takes too long to finish a task after switching to the foreground. // It takes too long to finish a task after switching to the foreground.
...@@ -330,11 +334,12 @@ TEST_F(GpuWatchdogPowerTest, GpuOnSuspend) { ...@@ -330,11 +334,12 @@ TEST_F(GpuWatchdogPowerTest, GpuOnSuspend) {
power_monitor_source_->GenerateSuspendEvent(); power_monitor_source_->GenerateSuspendEvent();
// Run a task that takes longer (5000 milliseconds) than timeout. // Run a task that takes longer (5000 milliseconds) than timeout.
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 + base::BindOnce(&SimpleTask, kGpuWatchdogTimeoutForTesting * 2 +
base::TimeDelta::FromMilliseconds(3000))); base::TimeDelta::FromMilliseconds(3000)));
main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); task_environment_.GetMainThreadTaskRunner()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
// A task might take long time to finish after entering suspension mode. // A task might take long time to finish after entering suspension mode.
...@@ -350,7 +355,7 @@ TEST_F(GpuWatchdogPowerTest, GpuOnResumeHang) { ...@@ -350,7 +355,7 @@ TEST_F(GpuWatchdogPowerTest, GpuOnResumeHang) {
// wakes up on power resume and then runs for 6000 milliseconds. This is // wakes up on power resume and then runs for 6000 milliseconds. This is
// longer than the watchdog resume timeout (2000 ms). // longer than the watchdog resume timeout (2000 ms).
#if defined(OS_WIN) #if defined(OS_WIN)
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&GpuWatchdogPowerTest::LongTaskOnResume, base::Unretained(this), &GpuWatchdogPowerTest::LongTaskOnResume, base::Unretained(this),
...@@ -361,7 +366,7 @@ TEST_F(GpuWatchdogPowerTest, GpuOnResumeHang) { ...@@ -361,7 +366,7 @@ TEST_F(GpuWatchdogPowerTest, GpuOnResumeHang) {
/*time_to_power_resume*/ /*time_to_power_resume*/
base::TimeDelta::FromMilliseconds(200))); base::TimeDelta::FromMilliseconds(200)));
#else #else
main_loop.task_runner()->PostTask( task_environment_.GetMainThreadTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
&GpuWatchdogPowerTest::LongTaskOnResume, base::Unretained(this), &GpuWatchdogPowerTest::LongTaskOnResume, base::Unretained(this),
...@@ -371,7 +376,8 @@ TEST_F(GpuWatchdogPowerTest, GpuOnResumeHang) { ...@@ -371,7 +376,8 @@ TEST_F(GpuWatchdogPowerTest, GpuOnResumeHang) {
base::TimeDelta::FromMilliseconds(200))); base::TimeDelta::FromMilliseconds(200)));
#endif #endif
main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure()); task_environment_.GetMainThreadTaskRunner()->PostTask(FROM_HERE,
run_loop.QuitClosure());
run_loop.Run(); run_loop.Run();
// It takes too long to finish this task after power resume. A GPU hang should // It takes too long to finish this task after power resume. A GPU hang should
......
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