Index: gpu/command_buffer/service/gpu_tracer_unittest.cc |
diff --git a/gpu/command_buffer/service/gpu_tracer_unittest.cc b/gpu/command_buffer/service/gpu_tracer_unittest.cc |
index 900542193cc3e999b9535cbe9ccccfebe8e83962..a289d05cc6a70ea0c2f299705012c99874d9ecc0 100644 |
--- a/gpu/command_buffer/service/gpu_tracer_unittest.cc |
+++ b/gpu/command_buffer/service/gpu_tracer_unittest.cc |
@@ -150,9 +150,9 @@ class GlFakeQueries { |
class GPUTracerTester : public GPUTracer { |
public: |
- explicit GPUTracerTester(gles2::GLES2Decoder* decoder) |
- : GPUTracer(decoder), tracing_enabled_(0) { |
- gpu_timing_.SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); |
+ explicit GPUTracerTester(gles2::GLES2Decoder* decoder, GPUTiming* gpu_timing) |
Daniele Castagna
2015/02/19 18:15:32
nit: explicit here is not needed anymore.
|
+ : GPUTracer(decoder, gpu_timing), tracing_enabled_(0) { |
+ gpu_timing_->SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); |
// Force tracing to be dependent on our mock variable here. |
gpu_trace_srv_category = &tracing_enabled_; |
@@ -406,7 +406,7 @@ class BaseGpuTracerTest : public BaseGpuTest { |
MockGLES2Decoder decoder; |
EXPECT_CALL(decoder, GetGLContext()).WillOnce(Return(GetGLContext())); |
- GPUTracerTester tracer(&decoder); |
+ GPUTracerTester tracer(&decoder, &gpu_timing_); |
tracer.SetTracingEnabled(true); |
tracer.SetOutputter(outputter_ref_); |
@@ -437,7 +437,7 @@ class BaseGpuTracerTest : public BaseGpuTest { |
MockGLES2Decoder decoder; |
EXPECT_CALL(decoder, GetGLContext()).WillOnce(Return(GetGLContext())); |
- GPUTracerTester tracer(&decoder); |
+ GPUTracerTester tracer(&decoder, &gpu_timing_); |
tracer.SetTracingEnabled(true); |
tracer.SetOutputter(outputter_ref_); |
@@ -522,7 +522,7 @@ class BaseGpuTracerTest : public BaseGpuTest { |
MockGLES2Decoder decoder; |
EXPECT_CALL(decoder, GetGLContext()).WillOnce(Return(GetGLContext())); |
- GPUTracerTester tracer(&decoder); |
+ GPUTracerTester tracer(&decoder, &gpu_timing_); |
tracer.SetTracingEnabled(true); |
tracer.SetOutputter(outputter_ref_); |
@@ -540,7 +540,15 @@ class BaseGpuTracerTest : public BaseGpuTest { |
gl_fake_queries_.SetCurrentGLTime(end_timestamp); |
g_fakeCPUTime = expect_end_time; |
+ |
+ // Create a disjoint context to test disjoint behavior. This should not |
+ // interfere with the tracer's disjoint context. |
+ scoped_refptr<DisjointContext> disjoint_context = |
+ gpu_timing_.CreateDisjointContext(); |
+ |
+ ASSERT_FALSE(disjoint_context->CheckAndResetTimerErrors()); |
gl_fake_queries_.SetDisjoint(); |
+ ASSERT_TRUE(disjoint_context->CheckAndResetTimerErrors()); |
ExpectOutputterEndMocks(outputter_ref_.get(), category_name, trace_name, |
expect_start_time, expect_end_time, false); |
@@ -605,7 +613,7 @@ class GPUTracerTest : public GpuServiceTest { |
EXPECT_CALL(*decoder_, GetGLContext()) |
.Times(AtMost(1)) |
.WillRepeatedly(Return(GetGLContext())); |
- tracer_tester_.reset(new GPUTracerTester(decoder_.get())); |
+ tracer_tester_.reset(new GPUTracerTester(decoder_.get(), &gpu_timing_)); |
} |
void TearDown() override { |
@@ -613,6 +621,7 @@ class GPUTracerTest : public GpuServiceTest { |
decoder_ = nullptr; |
GpuServiceTest::TearDown(); |
} |
+ GPUTiming gpu_timing_; |
scoped_ptr<MockGLES2Decoder> decoder_; |
scoped_ptr<GPUTracerTester> tracer_tester_; |
}; |
@@ -643,6 +652,49 @@ TEST_F(GPUTracerTest, TraceDuringDecodeTest) { |
ASSERT_TRUE(tracer_tester_->EndDecoding()); |
} |
+TEST_F(GpuDisjointTimerTracerTest, MultipleDisjointContexts) { |
+ EXPECT_CALL(*gl_, GetIntegerv(GL_GPU_DISJOINT_EXT, _)).Times(AtLeast(1)) |
+ .WillRepeatedly( |
+ Invoke(&gl_fake_queries_, &GlFakeQueries::GetIntegerv)); |
+ |
+ scoped_refptr<DisjointContext> disjoint_context1 = |
+ gpu_timing_.CreateDisjointContext(); |
+ scoped_refptr<DisjointContext> disjoint_context2 = |
+ gpu_timing_.CreateDisjointContext(); |
+ |
+ // Test both contexts are initialized as no errors. |
+ ASSERT_FALSE(disjoint_context1->CheckAndResetTimerErrors()); |
+ ASSERT_FALSE(disjoint_context2->CheckAndResetTimerErrors()); |
+ |
+ // Issue a disjoint. |
+ gl_fake_queries_.SetDisjoint(); |
+ |
+ ASSERT_TRUE(disjoint_context1->CheckAndResetTimerErrors()); |
+ ASSERT_TRUE(disjoint_context2->CheckAndResetTimerErrors()); |
+ |
+ // Test new context gets the disjoint value as if no other contexts reset it. |
+ scoped_refptr<DisjointContext> disjoint_context3 = |
+ gpu_timing_.CreateDisjointContext(); |
+ ASSERT_TRUE(disjoint_context3->CheckAndResetTimerErrors()); |
+ |
+ // Test all 3 are all reset. |
+ ASSERT_FALSE(disjoint_context1->CheckAndResetTimerErrors()); |
+ ASSERT_FALSE(disjoint_context2->CheckAndResetTimerErrors()); |
+ ASSERT_FALSE(disjoint_context3->CheckAndResetTimerErrors()); |
+} |
+ |
+TEST_F(GpuDisjointTimerTracerTest, DisjointContextDestruction) { |
+ ASSERT_EQ(0u, gpu_timing_.GetDisjointContextsCount()); |
+ |
+ { |
+ scoped_refptr<DisjointContext> context = |
+ gpu_timing_.CreateDisjointContext(); |
+ ASSERT_EQ(1u, gpu_timing_.GetDisjointContextsCount()); |
+ } |
+ |
+ ASSERT_EQ(0u, gpu_timing_.GetDisjointContextsCount()); |
+} |
+ |
} // namespace |
} // namespace gles2 |
} // namespace gpu |