OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 6 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
7 #include "gpu/command_buffer/service/gpu_service_test.h" | 7 #include "gpu/command_buffer/service/gpu_service_test.h" |
8 #include "gpu/command_buffer/service/gpu_tracer.h" | 8 #include "gpu/command_buffer/service/gpu_tracer.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/gl/gl_mock.h" | 10 #include "ui/gl/gl_mock.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 }; | 213 }; |
214 | 214 |
215 // Test GPUTrace calls all the correct gl calls. | 215 // Test GPUTrace calls all the correct gl calls. |
216 class BaseGpuTraceTest : public BaseGpuTest { | 216 class BaseGpuTraceTest : public BaseGpuTest { |
217 public: | 217 public: |
218 explicit BaseGpuTraceTest(gfx::GPUTiming::TimerType test_timer_type) | 218 explicit BaseGpuTraceTest(gfx::GPUTiming::TimerType test_timer_type) |
219 : BaseGpuTest(test_timer_type) {} | 219 : BaseGpuTest(test_timer_type) {} |
220 | 220 |
221 void DoTraceTest(bool tracing_service, bool tracing_device) { | 221 void DoTraceTest(bool tracing_service, bool tracing_device) { |
222 // Expected results | 222 // Expected results |
223 const GpuTracerSource tracer_source = kTraceGroupMarker; | 223 const GpuTracerSource tracer_source = kTraceCHROMIUM; |
224 const std::string category_name("trace_category"); | 224 const std::string category_name("trace_category"); |
225 const std::string trace_name("trace_test"); | 225 const std::string trace_name("trace_test"); |
226 const int64 offset_time = 3231; | 226 const int64 offset_time = 3231; |
227 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; | 227 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; |
228 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; | 228 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; |
229 const int64 expect_start_time = | 229 const int64 expect_start_time = |
230 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + | 230 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + |
231 offset_time; | 231 offset_time; |
232 const int64 expect_end_time = | 232 const int64 expect_end_time = |
233 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; | 233 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 } | 415 } |
416 ASSERT_TRUE(tracer.EndDecoding()); | 416 ASSERT_TRUE(tracer.EndDecoding()); |
417 outputter_ref_ = NULL; | 417 outputter_ref_ = NULL; |
418 } | 418 } |
419 | 419 |
420 void DoDisjointTest() { | 420 void DoDisjointTest() { |
421 // Cause a disjoint in a middle of a trace and expect no output calls. | 421 // Cause a disjoint in a middle of a trace and expect no output calls. |
422 ExpectTracerOffsetQueryMocks(); | 422 ExpectTracerOffsetQueryMocks(); |
423 gl_fake_queries_.ExpectGetErrorCalls(*gl_); | 423 gl_fake_queries_.ExpectGetErrorCalls(*gl_); |
424 | 424 |
425 const GpuTracerSource tracer_source = kTraceGroupMarker; | 425 const GpuTracerSource tracer_source = kTraceCHROMIUM; |
426 const std::string category_name("trace_category"); | 426 const std::string category_name("trace_category"); |
427 const std::string trace_name("trace_test"); | 427 const std::string trace_name("trace_test"); |
428 const GpuTracerSource source = static_cast<GpuTracerSource>(0); | 428 const GpuTracerSource source = static_cast<GpuTracerSource>(0); |
429 const int64 offset_time = 3231; | 429 const int64 offset_time = 3231; |
430 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; | 430 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; |
431 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; | 431 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; |
432 const int64 expect_start_time = | 432 const int64 expect_start_time = |
433 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + | 433 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + |
434 offset_time; | 434 offset_time; |
435 const int64 expect_end_time = | 435 const int64 expect_end_time = |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 EXPECT_FALSE(tracer_tester_->BeginDecoding()); | 572 EXPECT_FALSE(tracer_tester_->BeginDecoding()); |
573 ASSERT_TRUE(tracer_tester_->EndDecoding()); | 573 ASSERT_TRUE(tracer_tester_->EndDecoding()); |
574 EXPECT_FALSE(tracer_tester_->EndDecoding()); | 574 EXPECT_FALSE(tracer_tester_->EndDecoding()); |
575 } | 575 } |
576 | 576 |
577 TEST_F(GPUTracerTest, TraceDuringDecodeTest) { | 577 TEST_F(GPUTracerTest, TraceDuringDecodeTest) { |
578 const std::string category_name("trace_category"); | 578 const std::string category_name("trace_category"); |
579 const std::string trace_name("trace_test"); | 579 const std::string trace_name("trace_test"); |
580 | 580 |
581 EXPECT_FALSE( | 581 EXPECT_FALSE( |
582 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); | 582 tracer_tester_->Begin(category_name, trace_name, kTraceCHROMIUM)); |
583 | 583 |
584 ASSERT_TRUE(tracer_tester_->BeginDecoding()); | 584 ASSERT_TRUE(tracer_tester_->BeginDecoding()); |
585 EXPECT_TRUE( | 585 EXPECT_TRUE( |
586 tracer_tester_->Begin(category_name, trace_name, kTraceGroupMarker)); | 586 tracer_tester_->Begin(category_name, trace_name, kTraceCHROMIUM)); |
587 ASSERT_TRUE(tracer_tester_->EndDecoding()); | 587 ASSERT_TRUE(tracer_tester_->EndDecoding()); |
588 } | 588 } |
589 | 589 |
590 TEST_F(GpuDisjointTimerTracerTest, MultipleClientsDisjointTest) { | 590 TEST_F(GpuDisjointTimerTracerTest, MultipleClientsDisjointTest) { |
591 scoped_refptr<gfx::GPUTimingClient> client1 = | 591 scoped_refptr<gfx::GPUTimingClient> client1 = |
592 GetGLContext()->CreateGPUTimingClient(); | 592 GetGLContext()->CreateGPUTimingClient(); |
593 scoped_refptr<gfx::GPUTimingClient> client2 = | 593 scoped_refptr<gfx::GPUTimingClient> client2 = |
594 GetGLContext()->CreateGPUTimingClient(); | 594 GetGLContext()->CreateGPUTimingClient(); |
595 | 595 |
596 // Test both clients are initialized as no errors. | 596 // Test both clients are initialized as no errors. |
(...skipping 17 matching lines...) Expand all Loading... |
614 scoped_refptr<gfx::GPUTimingClient> client3 = | 614 scoped_refptr<gfx::GPUTimingClient> client3 = |
615 GetGLContext()->CreateGPUTimingClient(); | 615 GetGLContext()->CreateGPUTimingClient(); |
616 ASSERT_TRUE(client1->CheckAndResetTimerErrors()); | 616 ASSERT_TRUE(client1->CheckAndResetTimerErrors()); |
617 ASSERT_TRUE(client2->CheckAndResetTimerErrors()); | 617 ASSERT_TRUE(client2->CheckAndResetTimerErrors()); |
618 ASSERT_FALSE(client3->CheckAndResetTimerErrors()); | 618 ASSERT_FALSE(client3->CheckAndResetTimerErrors()); |
619 } | 619 } |
620 | 620 |
621 } // namespace | 621 } // namespace |
622 } // namespace gles2 | 622 } // namespace gles2 |
623 } // namespace gpu | 623 } // namespace gpu |
OLD | NEW |