| 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 <map> | 5 #include <map> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
| 10 #include "gpu/command_buffer/service/gpu_service_test.h" | 10 #include "gpu/command_buffer/service/gpu_service_test.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 gpu_timing_client_ = GetGLContext()->CreateGPUTimingClient(); | 222 gpu_timing_client_ = GetGLContext()->CreateGPUTimingClient(); |
| 223 gpu_timing_client_->SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); | 223 gpu_timing_client_->SetCpuTimeForTesting(base::Bind(&FakeCpuTime)); |
| 224 gl_fake_queries_.Reset(); | 224 gl_fake_queries_.Reset(); |
| 225 | 225 |
| 226 outputter_ref_ = new MockOutputter(); | 226 outputter_ref_ = new MockOutputter(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void TearDown() override { | 229 void TearDown() override { |
| 230 outputter_ref_ = NULL; | 230 outputter_ref_ = NULL; |
| 231 gpu_timing_client_ = NULL; |
| 231 | 232 |
| 232 gl_fake_queries_.Reset(); | 233 gl_fake_queries_.Reset(); |
| 233 GpuServiceTest::TearDown(); | 234 GpuServiceTest::TearDown(); |
| 234 } | 235 } |
| 235 | 236 |
| 236 void ExpectTraceQueryMocks() { | 237 void ExpectTraceQueryMocks() { |
| 237 if (gpu_timing_client_->IsAvailable() && | 238 if (gpu_timing_client_->IsAvailable() && |
| 238 gpu_timing_client_->IsTimerOffsetAvailable()) { | 239 gpu_timing_client_->IsTimerOffsetAvailable()) { |
| 239 // Delegate query APIs used by GPUTrace to a GlFakeQueries | 240 // Delegate query APIs used by GPUTrace to a GlFakeQueries |
| 240 EXPECT_CALL(*gl_, GenQueries(2, NotNull())).Times(AtLeast(1)) | 241 EXPECT_CALL(*gl_, GenQueries(2, NotNull())).Times(AtLeast(1)) |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 base::Time::kNanosecondsPerMicrosecond); | 368 base::Time::kNanosecondsPerMicrosecond); |
| 368 EXPECT_FALSE(trace->IsAvailable()); | 369 EXPECT_FALSE(trace->IsAvailable()); |
| 369 | 370 |
| 370 // Now it should be available | 371 // Now it should be available |
| 371 gl_fake_queries_.SetCurrentGLTime(end_timestamp); | 372 gl_fake_queries_.SetCurrentGLTime(end_timestamp); |
| 372 EXPECT_TRUE(trace->IsAvailable()); | 373 EXPECT_TRUE(trace->IsAvailable()); |
| 373 | 374 |
| 374 // Proces should output expected Trace results to MockOutputter | 375 // Proces should output expected Trace results to MockOutputter |
| 375 trace->Process(); | 376 trace->Process(); |
| 376 | 377 |
| 378 // Destroy trace after we are done. |
| 379 trace->Destroy(true); |
| 380 |
| 377 outputter_ref_ = NULL; | 381 outputter_ref_ = NULL; |
| 378 } | 382 } |
| 379 }; | 383 }; |
| 380 | 384 |
| 381 class GpuARBTimerTraceTest : public BaseGpuTraceTest { | 385 class GpuARBTimerTraceTest : public BaseGpuTraceTest { |
| 382 public: | 386 public: |
| 383 GpuARBTimerTraceTest() : BaseGpuTraceTest(gfx::GPUTiming::kTimerTypeARB) {} | 387 GpuARBTimerTraceTest() : BaseGpuTraceTest(gfx::GPUTiming::kTimerTypeARB) {} |
| 384 }; | 388 }; |
| 385 | 389 |
| 386 class GpuDisjointTimerTraceTest : public BaseGpuTraceTest { | 390 class GpuDisjointTimerTraceTest : public BaseGpuTraceTest { |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 scoped_refptr<gfx::GPUTimingClient> client3 = | 702 scoped_refptr<gfx::GPUTimingClient> client3 = |
| 699 GetGLContext()->CreateGPUTimingClient(); | 703 GetGLContext()->CreateGPUTimingClient(); |
| 700 ASSERT_TRUE(client1->CheckAndResetTimerErrors()); | 704 ASSERT_TRUE(client1->CheckAndResetTimerErrors()); |
| 701 ASSERT_TRUE(client2->CheckAndResetTimerErrors()); | 705 ASSERT_TRUE(client2->CheckAndResetTimerErrors()); |
| 702 ASSERT_FALSE(client3->CheckAndResetTimerErrors()); | 706 ASSERT_FALSE(client3->CheckAndResetTimerErrors()); |
| 703 } | 707 } |
| 704 | 708 |
| 705 } // namespace | 709 } // namespace |
| 706 } // namespace gles2 | 710 } // namespace gles2 |
| 707 } // namespace gpu | 711 } // namespace gpu |
| OLD | NEW |