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