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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/time.h" | 7 #include "base/time.h" |
8 #include "content/browser/gpu/gpu_data_manager_impl.h" | 8 #include "content/browser/gpu/gpu_data_manager_impl.h" |
9 #include "content/public/browser/gpu_data_manager_observer.h" | 9 #include "content/public/browser/gpu_data_manager_observer.h" |
10 #include "content/public/common/gpu_info.h" | 10 #include "content/public/common/gpu_info.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 EXPECT_TRUE(manager->GpuAccessAllowed()); | 187 EXPECT_TRUE(manager->GpuAccessAllowed()); |
188 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); | 188 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); |
189 | 189 |
190 // Now assume gpu process launches and full GPU info is collected. | 190 // Now assume gpu process launches and full GPU info is collected. |
191 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 191 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
192 manager->UpdateGpuInfo(gpu_info); | 192 manager->UpdateGpuInfo(gpu_info); |
193 EXPECT_TRUE(manager->GpuAccessAllowed()); | 193 EXPECT_TRUE(manager->GpuAccessAllowed()); |
194 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); | 194 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); |
195 } | 195 } |
196 | 196 |
197 TEST_F(GpuDataManagerImplTest, BlacklistCard) { | 197 TEST_F(GpuDataManagerImplTest, DisableHardwareAcceleration) { |
198 ScopedGpuDataManagerImpl manager; | 198 ScopedGpuDataManagerImpl manager; |
199 ASSERT_TRUE(manager.get()); | 199 ASSERT_TRUE(manager.get()); |
200 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); | 200 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); |
201 EXPECT_TRUE(manager->GpuAccessAllowed()); | 201 EXPECT_TRUE(manager->GpuAccessAllowed()); |
202 | 202 |
203 manager->BlacklistCard(); | 203 manager->DisableHardwareAcceleration(); |
204 EXPECT_FALSE(manager->GpuAccessAllowed()); | 204 EXPECT_FALSE(manager->GpuAccessAllowed()); |
205 EXPECT_EQ(GPU_FEATURE_TYPE_ALL, manager->GetBlacklistedFeatures()); | 205 EXPECT_EQ(GPU_FEATURE_TYPE_ALL, manager->GetBlacklistedFeatures()); |
206 } | 206 } |
207 | 207 |
208 TEST_F(GpuDataManagerImplTest, SoftwareRendering) { | 208 TEST_F(GpuDataManagerImplTest, SoftwareRendering) { |
209 // Blacklist, then register SwiftShader. | 209 // Blacklist, then register SwiftShader. |
210 ScopedGpuDataManagerImpl manager; | 210 ScopedGpuDataManagerImpl manager; |
211 ASSERT_TRUE(manager.get()); | 211 ASSERT_TRUE(manager.get()); |
212 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); | 212 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); |
213 EXPECT_TRUE(manager->GpuAccessAllowed()); | 213 EXPECT_TRUE(manager->GpuAccessAllowed()); |
214 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); | 214 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); |
215 | 215 |
216 manager->BlacklistCard(); | 216 manager->DisableHardwareAcceleration(); |
217 EXPECT_FALSE(manager->GpuAccessAllowed()); | 217 EXPECT_FALSE(manager->GpuAccessAllowed()); |
218 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); | 218 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); |
219 | 219 |
220 // If software rendering is enabled, even if we blacklist GPU, | 220 // If software rendering is enabled, even if we blacklist GPU, |
221 // GPU process is still allowed. | 221 // GPU process is still allowed. |
222 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); | 222 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
223 manager->RegisterSwiftShaderPath(test_path); | 223 manager->RegisterSwiftShaderPath(test_path); |
224 EXPECT_TRUE(manager->ShouldUseSoftwareRendering()); | 224 EXPECT_TRUE(manager->ShouldUseSoftwareRendering()); |
225 EXPECT_TRUE(manager->GpuAccessAllowed()); | 225 EXPECT_TRUE(manager->GpuAccessAllowed()); |
226 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, | 226 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, |
227 manager->GetBlacklistedFeatures()); | 227 manager->GetBlacklistedFeatures()); |
228 } | 228 } |
229 | 229 |
230 TEST_F(GpuDataManagerImplTest, SoftwareRendering2) { | 230 TEST_F(GpuDataManagerImplTest, SoftwareRendering2) { |
231 // Register SwiftShader, then blacklist. | 231 // Register SwiftShader, then blacklist. |
232 ScopedGpuDataManagerImpl manager; | 232 ScopedGpuDataManagerImpl manager; |
233 ASSERT_TRUE(manager.get()); | 233 ASSERT_TRUE(manager.get()); |
234 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); | 234 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); |
235 EXPECT_TRUE(manager->GpuAccessAllowed()); | 235 EXPECT_TRUE(manager->GpuAccessAllowed()); |
236 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); | 236 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); |
237 | 237 |
238 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); | 238 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
239 manager->RegisterSwiftShaderPath(test_path); | 239 manager->RegisterSwiftShaderPath(test_path); |
240 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); | 240 EXPECT_EQ(0, manager->GetBlacklistedFeatures()); |
241 EXPECT_TRUE(manager->GpuAccessAllowed()); | 241 EXPECT_TRUE(manager->GpuAccessAllowed()); |
242 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); | 242 EXPECT_FALSE(manager->ShouldUseSoftwareRendering()); |
243 | 243 |
244 manager->BlacklistCard(); | 244 manager->DisableHardwareAcceleration(); |
245 EXPECT_TRUE(manager->GpuAccessAllowed()); | 245 EXPECT_TRUE(manager->GpuAccessAllowed()); |
246 EXPECT_TRUE(manager->ShouldUseSoftwareRendering()); | 246 EXPECT_TRUE(manager->ShouldUseSoftwareRendering()); |
247 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, | 247 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, |
248 manager->GetBlacklistedFeatures()); | 248 manager->GetBlacklistedFeatures()); |
249 } | 249 } |
250 | 250 |
251 TEST_F(GpuDataManagerImplTest, GpuInfoUpdate) { | 251 TEST_F(GpuDataManagerImplTest, GpuInfoUpdate) { |
252 ScopedGpuDataManagerImpl manager; | 252 ScopedGpuDataManagerImpl manager; |
253 ASSERT_TRUE(manager.get()); | 253 ASSERT_TRUE(manager.get()); |
254 | 254 |
(...skipping 12 matching lines...) Expand all Loading... |
267 base::RunLoop run_loop; | 267 base::RunLoop run_loop; |
268 run_loop.RunUntilIdle(); | 268 run_loop.RunUntilIdle(); |
269 } | 269 } |
270 EXPECT_TRUE(observer.gpu_info_updated()); | 270 EXPECT_TRUE(observer.gpu_info_updated()); |
271 } | 271 } |
272 | 272 |
273 TEST_F(GpuDataManagerImplTest, NoGpuInfoUpdateWithSoftwareRendering) { | 273 TEST_F(GpuDataManagerImplTest, NoGpuInfoUpdateWithSoftwareRendering) { |
274 ScopedGpuDataManagerImpl manager; | 274 ScopedGpuDataManagerImpl manager; |
275 ASSERT_TRUE(manager.get()); | 275 ASSERT_TRUE(manager.get()); |
276 | 276 |
277 manager->BlacklistCard(); | 277 manager->DisableHardwareAcceleration(); |
278 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); | 278 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
279 manager->RegisterSwiftShaderPath(test_path); | 279 manager->RegisterSwiftShaderPath(test_path); |
280 EXPECT_TRUE(manager->ShouldUseSoftwareRendering()); | 280 EXPECT_TRUE(manager->ShouldUseSoftwareRendering()); |
281 EXPECT_TRUE(manager->GpuAccessAllowed()); | 281 EXPECT_TRUE(manager->GpuAccessAllowed()); |
282 | 282 |
283 { | 283 { |
284 base::RunLoop run_loop; | 284 base::RunLoop run_loop; |
285 run_loop.RunUntilIdle(); | 285 run_loop.RunUntilIdle(); |
286 } | 286 } |
287 | 287 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 // Now assume browser gets GL strings from local state. | 556 // Now assume browser gets GL strings from local state. |
557 // SetGLStrings() has no effects because GPUInfo already got these strings. | 557 // SetGLStrings() has no effects because GPUInfo already got these strings. |
558 // (Otherwise the entry should not apply.) | 558 // (Otherwise the entry should not apply.) |
559 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); | 559 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); |
560 EXPECT_TRUE(manager->GpuAccessAllowed()); | 560 EXPECT_TRUE(manager->GpuAccessAllowed()); |
561 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, manager->GetBlacklistedFeatures()); | 561 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, manager->GetBlacklistedFeatures()); |
562 } | 562 } |
563 #endif // OS_LINUX | 563 #endif // OS_LINUX |
564 | 564 |
565 } // namespace content | 565 } // namespace content |
OLD | NEW |