OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/gl/gpu_timing.h" | 5 #include "ui/gl/gpu_timing.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/gl/gl_context_stub_with_extensions.h" | 13 #include "ui/gl/gl_context_stub_with_extensions.h" |
14 #include "ui/gl/gl_implementation.h" | 14 #include "ui/gl/gl_implementation.h" |
15 #include "ui/gl/gl_mock.h" | 15 #include "ui/gl/gl_mock.h" |
16 #include "ui/gl/gl_surface_stub.h" | 16 #include "ui/gl/gl_surface_stub.h" |
17 #include "ui/gl/gpu_preference.h" | 17 #include "ui/gl/gpu_preference.h" |
18 #include "ui/gl/gpu_timing_fake.h" | 18 #include "ui/gl/gpu_timing_fake.h" |
19 #include "ui/gl/init/gl_factory.h" | |
20 #include "ui/gl/test/gl_surface_test_support.h" | 19 #include "ui/gl/test/gl_surface_test_support.h" |
21 | 20 |
22 namespace gl { | 21 namespace gl { |
23 | 22 |
24 using ::testing::Exactly; | 23 using ::testing::Exactly; |
25 using ::testing::NotNull; | 24 using ::testing::NotNull; |
26 using ::testing::DoAll; | 25 using ::testing::DoAll; |
27 using ::testing::Return; | 26 using ::testing::Return; |
28 using ::testing::SetArgPointee; | 27 using ::testing::SetArgPointee; |
29 | 28 |
30 class GPUTimingTest : public testing::Test { | 29 class GPUTimingTest : public testing::Test { |
31 public: | 30 public: |
32 void SetUp() override { | 31 void SetUp() override { |
33 setup_ = false; | 32 setup_ = false; |
34 cpu_time_bounded_ = false; | 33 cpu_time_bounded_ = false; |
35 } | 34 } |
36 | 35 |
37 void TearDown() override { | 36 void TearDown() override { |
38 context_ = nullptr; | 37 context_ = nullptr; |
39 surface_ = nullptr; | 38 surface_ = nullptr; |
40 if (setup_) { | 39 if (setup_) { |
41 MockGLInterface::SetGLInterface(NULL); | 40 MockGLInterface::SetGLInterface(NULL); |
42 init::ClearGLBindings(); | 41 ClearGLBindings(); |
43 } | 42 } |
44 setup_ = false; | 43 setup_ = false; |
45 cpu_time_bounded_ = false; | 44 cpu_time_bounded_ = false; |
46 gl_.reset(); | 45 gl_.reset(); |
47 gpu_timing_fake_queries_.Reset(); | 46 gpu_timing_fake_queries_.Reset(); |
48 } | 47 } |
49 | 48 |
50 void SetupGLContext(const char* gl_version, const char* gl_extensions) { | 49 void SetupGLContext(const char* gl_version, const char* gl_extensions) { |
51 ASSERT_FALSE(setup_) << "Cannot setup GL context twice."; | 50 ASSERT_FALSE(setup_) << "Cannot setup GL context twice."; |
52 SetGLGetProcAddressProc(MockGLInterface::GetGLProcAddress); | 51 SetGLGetProcAddressProc(MockGLInterface::GetGLProcAddress); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 208 |
210 int64_t start, end; | 209 int64_t start, end; |
211 gpu_timer->GetStartEndTimestamps(&start, &end); | 210 gpu_timer->GetStartEndTimestamps(&start, &end); |
212 // Force time elapsed won't be set until a query is actually attempted | 211 // Force time elapsed won't be set until a query is actually attempted |
213 ASSERT_TRUE(client->IsForceTimeElapsedQuery()); | 212 ASSERT_TRUE(client->IsForceTimeElapsedQuery()); |
214 EXPECT_EQ(begin_cpu_time, start); | 213 EXPECT_EQ(begin_cpu_time, start); |
215 EXPECT_EQ(begin_cpu_time, end); | 214 EXPECT_EQ(begin_cpu_time, end); |
216 } | 215 } |
217 | 216 |
218 } // namespace gl | 217 } // namespace gl |
OLD | NEW |