| Index: ui/gl/gpu_timing_unittest.cc
|
| diff --git a/ui/gl/gpu_timing_unittest.cc b/ui/gl/gpu_timing_unittest.cc
|
| index 8af9e26d44186cbd0f3a0646e29bce44e77c8ec4..fa5b1f1b7295175a107e3f96b29c075c31e0833a 100644
|
| --- a/ui/gl/gpu_timing_unittest.cc
|
| +++ b/ui/gl/gpu_timing_unittest.cc
|
| @@ -17,6 +17,12 @@
|
|
|
| namespace gfx {
|
|
|
| +using ::testing::Exactly;
|
| +using ::testing::NotNull;
|
| +using ::testing::DoAll;
|
| +using ::testing::Return;
|
| +using ::testing::SetArgPointee;
|
| +
|
| class GPUTimingTest : public testing::Test {
|
| public:
|
| void SetUp() override {
|
| @@ -163,4 +169,41 @@ TEST_F(GPUTimingTest, QueryTimeStampUsingElapsedTest) {
|
| EXPECT_EQ(begin_cpu_time, end);
|
| }
|
|
|
| +TEST_F(GPUTimingTest, QueryTimestampUsingElapsedARBTest) {
|
| + // Test timestamp queries on platforms with GL_ARB_timer_query but still lack
|
| + // support for timestamp queries
|
| + SetupGLContext("3.2", "GL_ARB_timer_query");
|
| + scoped_refptr<GPUTimingClient> client = CreateGPUTimingClient();
|
| + scoped_ptr<GPUTimer> gpu_timer = client->CreateGPUTimer(false);
|
| +
|
| + const int64_t begin_cpu_time = 123;
|
| + const int64_t begin_gl_time = 10 * base::Time::kNanosecondsPerMicrosecond;
|
| + const int64_t cpu_gl_offset = begin_gl_time - begin_cpu_time;
|
| + gpu_timing_fake_queries_.SetCPUGLOffset(cpu_gl_offset);
|
| + gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time);
|
| +
|
| + gpu_timing_fake_queries_.ExpectGPUTimeStampQuery(*gl_, true);
|
| +
|
| + // Custom mock override to ensure the timestamp bits are 0
|
| + EXPECT_CALL(*gl_, GetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, NotNull()))
|
| + .Times(Exactly(1))
|
| + .WillRepeatedly(DoAll(SetArgPointee<2>(0), Return()));
|
| +
|
| + gpu_timer->QueryTimeStamp();
|
| +
|
| + gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time - 1);
|
| + EXPECT_FALSE(gpu_timer->IsAvailable());
|
| +
|
| + gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time + 1);
|
| + EXPECT_TRUE(gpu_timer->IsAvailable());
|
| + EXPECT_EQ(0, gpu_timer->GetDeltaElapsed());
|
| +
|
| + int64_t start, end;
|
| + gpu_timer->GetStartEndTimestamps(&start, &end);
|
| + // Force time elapsed won't be set until a query is actually attempted
|
| + ASSERT_TRUE(client->IsForceTimeElapsedQuery());
|
| + EXPECT_EQ(begin_cpu_time, start);
|
| + EXPECT_EQ(begin_cpu_time, end);
|
| +}
|
| +
|
| } // namespace gpu
|
|
|