Skip to content

Commit

Permalink
Add two GPU watchdog unit tests
Browse files Browse the repository at this point in the history
GpuRunningATaskHang and ChromeInBackground tests are added. These new
tests cover OnBackgroundedand WillProcessTask functions.

Bug: 949839
Change-Id: Ied676321e94bec0efcf052fdab20a3271d6e9f26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1700642
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#677169}
  • Loading branch information
Maggie Chen authored and Commit Bot committed Jul 13, 2019
1 parent 3f683d5 commit ec1bc0c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions gpu/ipc/service/gpu_watchdog_thread_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,46 @@ TEST_F(GpuWatchdogTest, GpuInitializationAndRunningTasks) {
EXPECT_FALSE(result);
}

// GPU Hang when running a task
TEST_F(GpuWatchdogTest, GpuRunningATaskHang) {
// Report gpu init complete
watchdog_thread_->OnInitComplete();

// Start running a GPU task. This long task takes 3000 milliseconds to finish.
main_loop.task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&SimpleTask, kGpuWatchdogTimeout * 2 +
base::TimeDelta::FromMilliseconds(1000)));

main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();

// This GPU task takes too long. A GPU hang should be detected.
bool result = watchdog_thread_->IsGpuHangDetected();
EXPECT_TRUE(result);
}

TEST_F(GpuWatchdogTest, ChromeInBackground) {
// Chrome starts in the background.
watchdog_thread_->OnBackgrounded();

// Gpu init (2000 ms) takes longer than timeout (1000 ms).
SimpleTask(kGpuWatchdogTimeout + base::TimeDelta::FromMilliseconds(1000));

// Report GPU init complete.
watchdog_thread_->OnInitComplete();

// Run a task that takes longer (3000 milliseconds) than timeout.
main_loop.task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&SimpleTask, kGpuWatchdogTimeout * 2 +
base::TimeDelta::FromMilliseconds(1000)));
main_loop.task_runner()->PostTask(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();

// The gpu might be slow when running in the background. This is ok.
bool result = watchdog_thread_->IsGpuHangDetected();
EXPECT_FALSE(result);
}

} // namespace gpu

0 comments on commit ec1bc0c

Please sign in to comment.