1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
10 #include "gpu/command_buffer/service/gpu_service_test.h"
11 #include "gpu/command_buffer/service/gpu_tracer.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gl/gl_mock.h"
14 #include "ui/gl/gpu_timing.h"
21 using ::testing::AtLeast
;
22 using ::testing::AtMost
;
23 using ::testing::Exactly
;
24 using ::testing::Invoke
;
25 using ::testing::NotNull
;
26 using ::testing::Return
;
28 int64 g_fakeCPUTime
= 0;
33 class MockOutputter
: public Outputter
{
36 MOCK_METHOD4(TraceDevice
,
37 void(const std::string
& category
, const std::string
& name
,
38 int64 start_time
, int64 end_time
));
40 MOCK_METHOD2(TraceServiceBegin
,
41 void(const std::string
& category
, const std::string
& name
));
43 MOCK_METHOD2(TraceServiceEnd
,
44 void(const std::string
& category
, const std::string
& name
));
57 alloced_queries_
.clear();
58 query_timestamp_
.clear();
61 void SetCurrentGLTime(GLint64 current_time
) { current_time_
= current_time
; }
62 void SetDisjoint() { disjointed_
= true; }
64 void GenQueries(GLsizei n
, GLuint
* ids
) {
65 for (GLsizei i
= 0; i
< n
; i
++) {
66 ids
[i
] = next_query_id_
++;
67 alloced_queries_
.insert(ids
[i
]);
71 void DeleteQueries(GLsizei n
, const GLuint
* ids
) {
72 for (GLsizei i
= 0; i
< n
; i
++) {
73 alloced_queries_
.erase(ids
[i
]);
74 query_timestamp_
.erase(ids
[i
]);
78 void GetQueryObjectiv(GLuint id
, GLenum pname
, GLint
* params
) {
80 case GL_QUERY_RESULT_AVAILABLE
: {
81 std::map
<GLuint
, GLint64
>::iterator it
= query_timestamp_
.find(id
);
82 if (it
!= query_timestamp_
.end() && it
->second
<= current_time_
)
89 FAIL() << "Invalid variable passed to GetQueryObjectiv: " << pname
;
93 void QueryCounter(GLuint id
, GLenum target
) {
96 ASSERT_TRUE(alloced_queries_
.find(id
) != alloced_queries_
.end());
97 query_timestamp_
[id
] = current_time_
;
100 FAIL() << "Invalid variable passed to QueryCounter: " << target
;
104 void GetInteger64v(GLenum pname
, GLint64
* data
) {
107 *data
= current_time_
;
110 FAIL() << "Invalid variable passed to GetInteger64v: " << pname
;
114 void GetQueryObjectui64v(GLuint id
, GLenum pname
, GLuint64
* params
) {
116 case GL_QUERY_RESULT
:
117 ASSERT_TRUE(query_timestamp_
.find(id
) != query_timestamp_
.end());
118 *params
= query_timestamp_
.find(id
)->second
;
121 FAIL() << "Invalid variable passed to GetQueryObjectui64v: " << pname
;
125 void GetIntegerv(GLenum pname
, GLint
* params
) {
127 case GL_GPU_DISJOINT_EXT
:
128 *params
= static_cast<GLint
>(disjointed_
);
132 FAIL() << "Invalid variable passed to GetIntegerv: " << pname
;
144 bool disjointed_
= false;
145 GLint64 current_time_
= 0;
146 GLuint next_query_id_
= 0;
147 std::set
<GLuint
> alloced_queries_
;
148 std::map
<GLuint
, GLint64
> query_timestamp_
;
151 class GPUTracerTester
: public GPUTracer
{
153 explicit GPUTracerTester(gles2::GLES2Decoder
* decoder
)
154 : GPUTracer(decoder
), tracing_enabled_(0) {
155 gpu_timing_client_
->SetCpuTimeForTesting(base::Bind(&FakeCpuTime
));
157 // Force tracing to be dependent on our mock variable here.
158 gpu_trace_srv_category
= &tracing_enabled_
;
159 gpu_trace_dev_category
= &tracing_enabled_
;
162 ~GPUTracerTester() override
{}
164 void SetTracingEnabled(bool enabled
) {
165 tracing_enabled_
= enabled
? 1 : 0;
168 void SetOutputter(scoped_refptr
<Outputter
> outputter
) {
169 set_outputter_
= outputter
;
173 scoped_refptr
<Outputter
> CreateOutputter(const std::string
& name
) override
{
174 if (set_outputter_
.get()) {
175 return set_outputter_
;
177 return new MockOutputter();
180 void PostTask() override
{
181 // Process synchronously.
185 unsigned char tracing_enabled_
;
187 scoped_refptr
<Outputter
> set_outputter_
;
190 class BaseGpuTest
: public GpuServiceTest
{
192 explicit BaseGpuTest(gfx::GPUTiming::TimerType test_timer_type
)
193 : test_timer_type_(test_timer_type
) {
197 void SetUp() override
{
199 const char* gl_version
= "3.2";
200 const char* extensions
= "";
201 if (GetTimerType() == gfx::GPUTiming::kTimerTypeEXT
) {
202 gl_version
= "opengl 2.1";
203 extensions
= "GL_EXT_timer_query";
204 } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint
) {
205 gl_version
= "opengl es 3.0";
206 extensions
= "GL_EXT_disjoint_timer_query";
207 } else if (GetTimerType() == gfx::GPUTiming::kTimerTypeARB
) {
208 // TODO(sievers): The tracer should not depend on ARB_occlusion_query.
209 // Try merge Query APIs (core, ARB, EXT) into a single binding each.
210 extensions
= "GL_ARB_timer_query GL_ARB_occlusion_query";
212 GpuServiceTest::SetUpWithGLVersion(gl_version
, extensions
);
214 // Disjoint check should only be called by kTracerTypeDisjointTimer type.
215 if (GetTimerType() == gfx::GPUTiming::kTimerTypeDisjoint
) {
216 EXPECT_CALL(*gl_
, GetIntegerv(GL_GPU_DISJOINT_EXT
, _
)).Times(AtLeast(1))
218 Invoke(&gl_fake_queries_
, &GlFakeQueries::GetIntegerv
));
220 EXPECT_CALL(*gl_
, GetIntegerv(GL_GPU_DISJOINT_EXT
, _
)).Times(Exactly(0));
222 gpu_timing_client_
= GetGLContext()->CreateGPUTimingClient();
223 gpu_timing_client_
->SetCpuTimeForTesting(base::Bind(&FakeCpuTime
));
224 gl_fake_queries_
.Reset();
226 outputter_ref_
= new MockOutputter();
229 void TearDown() override
{
230 outputter_ref_
= NULL
;
231 gpu_timing_client_
= NULL
;
233 gl_fake_queries_
.Reset();
234 GpuServiceTest::TearDown();
237 void ExpectTraceQueryMocks() {
238 if (gpu_timing_client_
->IsAvailable() &&
239 gpu_timing_client_
->IsTimerOffsetAvailable()) {
240 // Delegate query APIs used by GPUTrace to a GlFakeQueries
241 EXPECT_CALL(*gl_
, GenQueries(2, NotNull())).Times(AtLeast(1))
243 Invoke(&gl_fake_queries_
, &GlFakeQueries::GenQueries
));
245 EXPECT_CALL(*gl_
, GetQueryObjectiv(_
, GL_QUERY_RESULT_AVAILABLE
,
248 Invoke(&gl_fake_queries_
, &GlFakeQueries::GetQueryObjectiv
));
250 EXPECT_CALL(*gl_
, GetInteger64v(GL_TIMESTAMP
, _
))
252 Invoke(&gl_fake_queries_
, &GlFakeQueries::GetInteger64v
));
254 EXPECT_CALL(*gl_
, QueryCounter(_
, GL_TIMESTAMP
)).Times(AtLeast(2))
256 Invoke(&gl_fake_queries_
, &GlFakeQueries::QueryCounter
));
258 EXPECT_CALL(*gl_
, GetQueryObjectui64v(_
, GL_QUERY_RESULT
, NotNull()))
260 Invoke(&gl_fake_queries_
,
261 &GlFakeQueries::GetQueryObjectui64v
));
263 EXPECT_CALL(*gl_
, DeleteQueries(2, NotNull())).Times(AtLeast(1))
265 Invoke(&gl_fake_queries_
, &GlFakeQueries::DeleteQueries
));
269 void ExpectOutputterBeginMocks(MockOutputter
* outputter
,
270 const std::string
& category
,
271 const std::string
& name
) {
272 EXPECT_CALL(*outputter
,
273 TraceServiceBegin(category
, name
));
276 void ExpectOutputterEndMocks(MockOutputter
* outputter
,
277 const std::string
& category
,
278 const std::string
& name
, int64 expect_start_time
,
279 int64 expect_end_time
,
281 EXPECT_CALL(*outputter
,
282 TraceServiceEnd(category
, name
));
285 EXPECT_CALL(*outputter
,
286 TraceDevice(category
, name
,
287 expect_start_time
, expect_end_time
))
290 EXPECT_CALL(*outputter
, TraceDevice(category
, name
,
291 expect_start_time
, expect_end_time
))
296 void ExpectOutputterMocks(MockOutputter
* outputter
,
297 const std::string
& category
,
298 const std::string
& name
, int64 expect_start_time
,
299 int64 expect_end_time
) {
300 ExpectOutputterBeginMocks(outputter
, category
, name
);
301 bool valid_timer
= gpu_timing_client_
->IsAvailable() &&
302 gpu_timing_client_
->IsTimerOffsetAvailable();
303 ExpectOutputterEndMocks(outputter
, category
, name
, expect_start_time
,
304 expect_end_time
, valid_timer
);
307 void ExpectTracerOffsetQueryMocks() {
308 if (GetTimerType() != gfx::GPUTiming::kTimerTypeARB
) {
309 EXPECT_CALL(*gl_
, GetInteger64v(GL_TIMESTAMP
, NotNull()))
312 EXPECT_CALL(*gl_
, GetInteger64v(GL_TIMESTAMP
, NotNull()))
315 Invoke(&gl_fake_queries_
, &GlFakeQueries::GetInteger64v
));
319 gfx::GPUTiming::TimerType
GetTimerType() { return test_timer_type_
; }
321 gfx::GPUTiming::TimerType test_timer_type_
;
322 GlFakeQueries gl_fake_queries_
;
324 scoped_refptr
<gfx::GPUTimingClient
> gpu_timing_client_
;
325 scoped_refptr
<MockOutputter
> outputter_ref_
;
328 // Test GPUTrace calls all the correct gl calls.
329 class BaseGpuTraceTest
: public BaseGpuTest
{
331 explicit BaseGpuTraceTest(gfx::GPUTiming::TimerType test_timer_type
)
332 : BaseGpuTest(test_timer_type
) {}
336 const std::string
category_name("trace_category");
337 const std::string
trace_name("trace_test");
338 const int64 offset_time
= 3231;
339 const GLint64 start_timestamp
= 7 * base::Time::kNanosecondsPerMicrosecond
;
340 const GLint64 end_timestamp
= 32 * base::Time::kNanosecondsPerMicrosecond
;
341 const int64 expect_start_time
=
342 (start_timestamp
/ base::Time::kNanosecondsPerMicrosecond
) +
344 const int64 expect_end_time
=
345 (end_timestamp
/ base::Time::kNanosecondsPerMicrosecond
) + offset_time
;
347 ExpectTraceQueryMocks();
348 ExpectOutputterMocks(outputter_ref_
.get(), category_name
, trace_name
,
349 expect_start_time
, expect_end_time
);
351 scoped_refptr
<GPUTrace
> trace
= new GPUTrace(
352 outputter_ref_
, gpu_timing_client_
.get(),
353 category_name
, trace_name
, true);
355 gl_fake_queries_
.SetCurrentGLTime(start_timestamp
);
356 g_fakeCPUTime
= expect_start_time
;
359 // Shouldn't be available before End() call
360 gl_fake_queries_
.SetCurrentGLTime(end_timestamp
);
361 g_fakeCPUTime
= expect_end_time
;
362 EXPECT_FALSE(trace
->IsAvailable());
366 // Shouldn't be available until the queries complete
367 gl_fake_queries_
.SetCurrentGLTime(end_timestamp
-
368 base::Time::kNanosecondsPerMicrosecond
);
369 EXPECT_FALSE(trace
->IsAvailable());
371 // Now it should be available
372 gl_fake_queries_
.SetCurrentGLTime(end_timestamp
);
373 EXPECT_TRUE(trace
->IsAvailable());
375 // Proces should output expected Trace results to MockOutputter
378 // Destroy trace after we are done.
379 trace
->Destroy(true);
381 outputter_ref_
= NULL
;
385 class GpuARBTimerTraceTest
: public BaseGpuTraceTest
{
387 GpuARBTimerTraceTest() : BaseGpuTraceTest(gfx::GPUTiming::kTimerTypeARB
) {}
390 class GpuDisjointTimerTraceTest
: public BaseGpuTraceTest
{
392 GpuDisjointTimerTraceTest()
393 : BaseGpuTraceTest(gfx::GPUTiming::kTimerTypeDisjoint
) {}
396 TEST_F(GpuARBTimerTraceTest
, ARBTimerTraceTest
) {
400 TEST_F(GpuDisjointTimerTraceTest
, DisjointTimerTraceTest
) {
404 // Test GPUTracer calls all the correct gl calls.
405 class BaseGpuTracerTest
: public BaseGpuTest
{
407 explicit BaseGpuTracerTest(gfx::GPUTiming::TimerType test_timer_type
)
408 : BaseGpuTest(test_timer_type
) {}
410 void DoBasicTracerTest() {
411 ExpectTracerOffsetQueryMocks();
413 MockGLES2Decoder decoder
;
414 EXPECT_CALL(decoder
, GetGLContext()).WillOnce(Return(GetGLContext()));
415 GPUTracerTester
tracer(&decoder
);
416 tracer
.SetTracingEnabled(true);
418 tracer
.SetOutputter(outputter_ref_
);
420 ASSERT_TRUE(tracer
.BeginDecoding());
421 ASSERT_TRUE(tracer
.EndDecoding());
423 outputter_ref_
= NULL
;
426 void DoTracerMarkersTest() {
427 ExpectTracerOffsetQueryMocks();
429 EXPECT_CALL(*gl_
, GetError()).Times(AtLeast(0))
431 Invoke(&gl_fake_queries_
, &GlFakeQueries::GetError
));
433 const std::string
category_name("trace_category");
434 const std::string
trace_name("trace_test");
435 const int64 offset_time
= 3231;
436 const GLint64 start_timestamp
= 7 * base::Time::kNanosecondsPerMicrosecond
;
437 const GLint64 end_timestamp
= 32 * base::Time::kNanosecondsPerMicrosecond
;
438 const int64 expect_start_time
=
439 (start_timestamp
/ base::Time::kNanosecondsPerMicrosecond
) +
441 const int64 expect_end_time
=
442 (end_timestamp
/ base::Time::kNanosecondsPerMicrosecond
) + offset_time
;
444 MockGLES2Decoder decoder
;
445 EXPECT_CALL(decoder
, GetGLContext()).WillOnce(Return(GetGLContext()));
446 GPUTracerTester
tracer(&decoder
);
447 tracer
.SetTracingEnabled(true);
449 tracer
.SetOutputter(outputter_ref_
);
451 gl_fake_queries_
.SetCurrentGLTime(start_timestamp
);
452 g_fakeCPUTime
= expect_start_time
;
454 ASSERT_TRUE(tracer
.BeginDecoding());
456 ExpectTraceQueryMocks();
458 // This will test multiple marker sources which overlap one another.
459 for (int i
= 0; i
< NUM_TRACER_SOURCES
; ++i
) {
460 // Set times so each source has a different time.
461 gl_fake_queries_
.SetCurrentGLTime(
463 (i
* base::Time::kNanosecondsPerMicrosecond
));
464 g_fakeCPUTime
= expect_start_time
+ i
;
466 // Each trace name should be different to differentiate.
467 const char num_char
= static_cast<char>('0' + i
);
468 std::string source_category
= category_name
+ num_char
;
469 std::string source_trace_name
= trace_name
+ num_char
;
471 ExpectOutputterBeginMocks(outputter_ref_
.get(),
472 source_category
, source_trace_name
);
474 const GpuTracerSource source
= static_cast<GpuTracerSource
>(i
);
475 ASSERT_TRUE(tracer
.Begin(source_category
, source_trace_name
, source
));
478 for (int i
= 0; i
< NUM_TRACER_SOURCES
; ++i
) {
479 // Set times so each source has a different time.
480 gl_fake_queries_
.SetCurrentGLTime(
482 (i
* base::Time::kNanosecondsPerMicrosecond
));
483 g_fakeCPUTime
= expect_end_time
+ i
;
485 // Each trace name should be different to differentiate.
486 const char num_char
= static_cast<char>('0' + i
);
487 std::string source_category
= category_name
+ num_char
;
488 std::string source_trace_name
= trace_name
+ num_char
;
490 bool valid_timer
= gpu_timing_client_
->IsAvailable() &&
491 gpu_timing_client_
->IsTimerOffsetAvailable();
492 ExpectOutputterEndMocks(outputter_ref_
.get(), source_category
,
493 source_trace_name
, expect_start_time
+ i
,
494 expect_end_time
+ i
, valid_timer
);
496 const GpuTracerSource source
= static_cast<GpuTracerSource
>(i
);
498 // Check if the current category/name are correct for this source.
499 ASSERT_EQ(source_category
, tracer
.CurrentCategory(source
));
500 ASSERT_EQ(source_trace_name
, tracer
.CurrentName(source
));
502 ASSERT_TRUE(tracer
.End(source
));
505 ASSERT_TRUE(tracer
.EndDecoding());
507 outputter_ref_
= NULL
;
510 void DoDisjointTest() {
511 // Cause a disjoint in a middle of a trace and expect no output calls.
512 ExpectTracerOffsetQueryMocks();
514 EXPECT_CALL(*gl_
, GetError()).Times(AtLeast(0))
516 Invoke(&gl_fake_queries_
, &GlFakeQueries::GetError
));
518 const std::string
category_name("trace_category");
519 const std::string
trace_name("trace_test");
520 const GpuTracerSource source
= static_cast<GpuTracerSource
>(0);
521 const int64 offset_time
= 3231;
522 const GLint64 start_timestamp
= 7 * base::Time::kNanosecondsPerMicrosecond
;
523 const GLint64 end_timestamp
= 32 * base::Time::kNanosecondsPerMicrosecond
;
524 const int64 expect_start_time
=
525 (start_timestamp
/ base::Time::kNanosecondsPerMicrosecond
) +
527 const int64 expect_end_time
=
528 (end_timestamp
/ base::Time::kNanosecondsPerMicrosecond
) + offset_time
;
530 MockGLES2Decoder decoder
;
531 EXPECT_CALL(decoder
, GetGLContext()).WillOnce(Return(GetGLContext()));
532 GPUTracerTester
tracer(&decoder
);
533 tracer
.SetTracingEnabled(true);
535 tracer
.SetOutputter(outputter_ref_
);
537 gl_fake_queries_
.SetCurrentGLTime(start_timestamp
);
538 g_fakeCPUTime
= expect_start_time
;
540 ASSERT_TRUE(tracer
.BeginDecoding());
542 ExpectTraceQueryMocks();
544 ExpectOutputterBeginMocks(outputter_ref_
.get(),
545 category_name
, trace_name
);
546 ASSERT_TRUE(tracer
.Begin(category_name
, trace_name
, source
));
548 gl_fake_queries_
.SetCurrentGLTime(end_timestamp
);
549 g_fakeCPUTime
= expect_end_time
;
551 // Create GPUTimingClient to make sure disjoint value is correct. This
552 // should not interfere with the tracer's disjoint value.
553 scoped_refptr
<gfx::GPUTimingClient
> disjoint_client
=
554 GetGLContext()->CreateGPUTimingClient();
556 // We assert here based on the disjoint_client because if disjoints are not
557 // working properly there is no point testing the tracer output.
558 ASSERT_FALSE(disjoint_client
->CheckAndResetTimerErrors());
559 gl_fake_queries_
.SetDisjoint();
560 ASSERT_TRUE(disjoint_client
->CheckAndResetTimerErrors());
562 ExpectOutputterEndMocks(outputter_ref_
.get(), category_name
, trace_name
,
563 expect_start_time
, expect_end_time
, false);
565 ASSERT_TRUE(tracer
.End(source
));
566 ASSERT_TRUE(tracer
.EndDecoding());
568 outputter_ref_
= NULL
;
572 class InvalidTimerTracerTest
: public BaseGpuTracerTest
{
574 InvalidTimerTracerTest()
575 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeInvalid
) {}
578 class GpuEXTTimerTracerTest
: public BaseGpuTracerTest
{
580 GpuEXTTimerTracerTest() : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeEXT
) {}
583 class GpuARBTimerTracerTest
: public BaseGpuTracerTest
{
585 GpuARBTimerTracerTest()
586 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeARB
) {}
589 class GpuDisjointTimerTracerTest
: public BaseGpuTracerTest
{
591 GpuDisjointTimerTracerTest()
592 : BaseGpuTracerTest(gfx::GPUTiming::kTimerTypeDisjoint
) {}
595 TEST_F(InvalidTimerTracerTest
, InvalidTimerBasicTracerTest
) {
599 TEST_F(GpuEXTTimerTracerTest
, EXTTimerBasicTracerTest
) {
603 TEST_F(GpuARBTimerTracerTest
, ARBTimerBasicTracerTest
) {
607 TEST_F(GpuDisjointTimerTracerTest
, DisjointTimerBasicTracerTest
) {
611 TEST_F(InvalidTimerTracerTest
, InvalidTimerTracerMarkersTest
) {
612 DoTracerMarkersTest();
615 TEST_F(GpuEXTTimerTracerTest
, EXTTimerTracerMarkersTest
) {
616 DoTracerMarkersTest();
619 TEST_F(GpuARBTimerTracerTest
, ARBTimerBasicTracerMarkersTest
) {
620 DoTracerMarkersTest();
623 TEST_F(GpuDisjointTimerTracerTest
, DisjointTimerBasicTracerMarkersTest
) {
624 DoTracerMarkersTest();
627 TEST_F(GpuDisjointTimerTracerTest
, DisjointTimerDisjointTraceTest
) {
631 class GPUTracerTest
: public GpuServiceTest
{
633 void SetUp() override
{
635 GpuServiceTest::SetUpWithGLVersion("3.2", "");
636 decoder_
.reset(new MockGLES2Decoder());
637 EXPECT_CALL(*decoder_
, GetGLContext())
639 .WillRepeatedly(Return(GetGLContext()));
640 tracer_tester_
.reset(new GPUTracerTester(decoder_
.get()));
643 void TearDown() override
{
644 tracer_tester_
= nullptr;
646 GpuServiceTest::TearDown();
648 scoped_ptr
<MockGLES2Decoder
> decoder_
;
649 scoped_ptr
<GPUTracerTester
> tracer_tester_
;
652 TEST_F(GPUTracerTest
, IsTracingTest
) {
653 EXPECT_FALSE(tracer_tester_
->IsTracing());
654 tracer_tester_
->SetTracingEnabled(true);
655 EXPECT_TRUE(tracer_tester_
->IsTracing());
657 // Test basic functionality of the GPUTracerTester.
658 TEST_F(GPUTracerTest
, DecodeTest
) {
659 ASSERT_TRUE(tracer_tester_
->BeginDecoding());
660 EXPECT_FALSE(tracer_tester_
->BeginDecoding());
661 ASSERT_TRUE(tracer_tester_
->EndDecoding());
662 EXPECT_FALSE(tracer_tester_
->EndDecoding());
665 TEST_F(GPUTracerTest
, TraceDuringDecodeTest
) {
666 const std::string
category_name("trace_category");
667 const std::string
trace_name("trace_test");
670 tracer_tester_
->Begin(category_name
, trace_name
, kTraceGroupMarker
));
672 ASSERT_TRUE(tracer_tester_
->BeginDecoding());
674 tracer_tester_
->Begin(category_name
, trace_name
, kTraceGroupMarker
));
675 ASSERT_TRUE(tracer_tester_
->EndDecoding());
678 TEST_F(GpuDisjointTimerTracerTest
, MultipleClientsDisjointTest
) {
679 scoped_refptr
<gfx::GPUTimingClient
> client1
=
680 GetGLContext()->CreateGPUTimingClient();
681 scoped_refptr
<gfx::GPUTimingClient
> client2
=
682 GetGLContext()->CreateGPUTimingClient();
684 // Test both clients are initialized as no errors.
685 ASSERT_FALSE(client1
->CheckAndResetTimerErrors());
686 ASSERT_FALSE(client2
->CheckAndResetTimerErrors());
689 gl_fake_queries_
.SetDisjoint();
691 ASSERT_TRUE(client1
->CheckAndResetTimerErrors());
692 ASSERT_TRUE(client2
->CheckAndResetTimerErrors());
694 // Test both are now reset.
695 ASSERT_FALSE(client1
->CheckAndResetTimerErrors());
696 ASSERT_FALSE(client2
->CheckAndResetTimerErrors());
699 gl_fake_queries_
.SetDisjoint();
701 // Test new client disjoint value is cleared.
702 scoped_refptr
<gfx::GPUTimingClient
> client3
=
703 GetGLContext()->CreateGPUTimingClient();
704 ASSERT_TRUE(client1
->CheckAndResetTimerErrors());
705 ASSERT_TRUE(client2
->CheckAndResetTimerErrors());
706 ASSERT_FALSE(client3
->CheckAndResetTimerErrors());