OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
11 #include "gpu/config/gpu_info.h" | 11 #include "gpu/config/gpu_info.h" |
12 #include "gpu/config/gpu_info_collector.h" | 12 #include "gpu/config/gpu_info_collector.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/gl/gl_context_stub.h" |
15 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
16 #include "ui/gl/gl_mock.h" | 17 #include "ui/gl/gl_mock.h" |
| 18 #include "ui/gl/gl_surface_stub.h" |
17 #include "ui/gl/init/gl_factory.h" | 19 #include "ui/gl/init/gl_factory.h" |
18 #include "ui/gl/test/gl_surface_test_support.h" | 20 #include "ui/gl/test/gl_surface_test_support.h" |
19 | 21 |
20 using ::gl::MockGLInterface; | 22 using ::gl::MockGLInterface; |
21 using ::testing::Return; | 23 using ::testing::Return; |
22 using ::testing::SetArgPointee; | 24 using ::testing::SetArgPointee; |
23 using ::testing::_; | 25 using ::testing::_; |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 "GL_EXT_read_format_bgra"; | 122 "GL_EXT_read_format_bgra"; |
121 gl_shading_language_version_ = "1.40 NVIDIA via Cg compiler"; | 123 gl_shading_language_version_ = "1.40 NVIDIA via Cg compiler"; |
122 break; | 124 break; |
123 } | 125 } |
124 default: { | 126 default: { |
125 NOTREACHED(); | 127 NOTREACHED(); |
126 break; | 128 break; |
127 } | 129 } |
128 } | 130 } |
129 | 131 |
| 132 // Need to make a context current so that WillUseGLGetStringForExtensions |
| 133 // can be called |
| 134 context_ = new gl::GLContextStub; |
| 135 context_->SetExtensionsString(test_values_.gl_extensions.c_str()); |
| 136 context_->SetGLVersionString(test_values_.gl_version.c_str()); |
| 137 surface_ = new gl::GLSurfaceStub; |
| 138 context_->MakeCurrent(surface_.get()); |
| 139 |
130 EXPECT_CALL(*gl_, GetString(GL_VERSION)) | 140 EXPECT_CALL(*gl_, GetString(GL_VERSION)) |
131 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( | 141 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( |
132 test_values_.gl_version.c_str()))); | 142 test_values_.gl_version.c_str()))); |
133 | 143 |
134 // Now that that expectation is set up, we can call this helper function. | 144 // Now that that expectation is set up, we can call this helper function. |
135 if (gl::WillUseGLGetStringForExtensions()) { | 145 if (gl::WillUseGLGetStringForExtensions()) { |
136 EXPECT_CALL(*gl_, GetString(GL_EXTENSIONS)) | 146 EXPECT_CALL(*gl_, GetString(GL_EXTENSIONS)) |
137 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( | 147 .WillRepeatedly(Return(reinterpret_cast<const GLubyte*>( |
138 test_values_.gl_extensions.c_str()))); | 148 test_values_.gl_extensions.c_str()))); |
139 } else { | 149 } else { |
(...skipping 28 matching lines...) Expand all Loading... |
168 gl_.reset(); | 178 gl_.reset(); |
169 gl::init::ShutdownGL(); | 179 gl::init::ShutdownGL(); |
170 | 180 |
171 testing::Test::TearDown(); | 181 testing::Test::TearDown(); |
172 } | 182 } |
173 | 183 |
174 public: | 184 public: |
175 // Use StrictMock to make 100% sure we know how GL will be called. | 185 // Use StrictMock to make 100% sure we know how GL will be called. |
176 std::unique_ptr<::testing::StrictMock<::gl::MockGLInterface>> gl_; | 186 std::unique_ptr<::testing::StrictMock<::gl::MockGLInterface>> gl_; |
177 GPUInfo test_values_; | 187 GPUInfo test_values_; |
| 188 scoped_refptr<gl::GLContextStub> context_; |
| 189 scoped_refptr<gl::GLSurfaceStub> surface_; |
178 const char* gl_shading_language_version_ = nullptr; | 190 const char* gl_shading_language_version_ = nullptr; |
179 | 191 |
180 // Persistent storage is needed for the split extension string. | 192 // Persistent storage is needed for the split extension string. |
181 std::vector<std::string> split_extensions_; | 193 std::vector<std::string> split_extensions_; |
182 }; | 194 }; |
183 | 195 |
184 INSTANTIATE_TEST_CASE_P(GPUConfig, | 196 INSTANTIATE_TEST_CASE_P(GPUConfig, |
185 GPUInfoCollectorTest, | 197 GPUInfoCollectorTest, |
186 ::testing::ValuesIn(kMockedOperatingSystemKinds)); | 198 ::testing::ValuesIn(kMockedOperatingSystemKinds)); |
187 | 199 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 435 |
424 gpu_info.gl_vendor = "Google Corporation"; | 436 gpu_info.gl_vendor = "Google Corporation"; |
425 gpu_info.gl_renderer = "Chrome GPU Team"; | 437 gpu_info.gl_renderer = "Chrome GPU Team"; |
426 IdentifyActiveGPU(&gpu_info); | 438 IdentifyActiveGPU(&gpu_info); |
427 EXPECT_FALSE(gpu_info.gpu.active); | 439 EXPECT_FALSE(gpu_info.gpu.active); |
428 EXPECT_FALSE(gpu_info.secondary_gpus[0].active); | 440 EXPECT_FALSE(gpu_info.secondary_gpus[0].active); |
429 } | 441 } |
430 | 442 |
431 } // namespace gpu | 443 } // namespace gpu |
432 | 444 |
OLD | NEW |