| Index: gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| index 63b175f6d80d07a90b29133a15905013253e263d..b1850c6e8bd1a4025ce13a50e84620f7ef8b14d3 100644
|
| --- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| +++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
|
| @@ -16,8 +16,11 @@
|
|
|
| #include <memory>
|
|
|
| +#include "base/bind.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/memory/ptr_util.h"
|
| +#include "base/test/test_mock_time_task_runner.h"
|
| +#include "base/threading/thread_task_runner_handle.h"
|
| #include "gpu/command_buffer/client/client_test_helper.h"
|
| #include "gpu/command_buffer/client/gles2_cmd_helper.h"
|
| #include "gpu/command_buffer/client/program_info_manager.h"
|
| @@ -4627,6 +4630,46 @@ TEST_F(GLES2ImplementationTest, ClientVisibility) {
|
| }
|
| }
|
|
|
| +TEST_F(GLES2ImplementationTest, ClientBusyBasic) {
|
| + auto runner = make_scoped_refptr(new base::TestMockTimeTaskRunner());
|
| + base::ThreadTaskRunnerHandle handle(runner);
|
| +
|
| + bool signaled = false;
|
| + gl_->SetIdleCallback(
|
| + base::Bind([](bool* signaled) { *signaled = true; }, &signaled), runner);
|
| + auto busy = gl_->ClientBecameBusy();
|
| + gl_->ClientBecameNotBusy(std::move(busy));
|
| +
|
| + runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
|
| + EXPECT_TRUE(signaled);
|
| +}
|
| +
|
| +TEST_F(GLES2ImplementationTest, ClientBusyCancelled) {
|
| + auto runner = make_scoped_refptr(new base::TestMockTimeTaskRunner());
|
| + base::ThreadTaskRunnerHandle handle(runner);
|
| +
|
| + bool signaled = false;
|
| + gl_->SetIdleCallback(
|
| + base::Bind([](bool* signaled) { *signaled = true; }, &signaled), runner);
|
| + auto busy = gl_->ClientBecameBusy();
|
| +
|
| + // This will trigger the idle callback to start counting down.
|
| + gl_->ClientBecameNotBusy(std::move(busy));
|
| +
|
| + // Immediately take another busy lock to stop the countdown.
|
| + busy = gl_->ClientBecameBusy();
|
| +
|
| + // Advance time and ensure that our callback was cancelled (does not run).
|
| + runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
|
| + EXPECT_FALSE(signaled);
|
| +
|
| + // Release our busy lock, and let the idle callback run.
|
| + gl_->ClientBecameNotBusy(std::move(busy));
|
| +
|
| + runner->FastForwardBy(base::TimeDelta::FromSeconds(5));
|
| + EXPECT_TRUE(signaled);
|
| +}
|
| +
|
| #include "base/macros.h"
|
| #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h"
|
|
|
|
|