Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: content/browser/gpu/gpu_data_manager_impl_private_unittest.cc

Issue 2715563002: Moving SwiftShader from component to bundled library (Closed)
Patch Set: Prevented !GpuAccessAllowed() from enabling SwiftShader Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 ); 173 );
174 174
175 gpu::GPUInfo gpu_info; 175 gpu::GPUInfo gpu_info;
176 gpu_info.gpu.vendor_id = 0x10de; 176 gpu_info.gpu.vendor_id = 0x10de;
177 gpu_info.gpu.device_id = 0x0640; 177 gpu_info.gpu.device_id = 0x0640;
178 manager->InitializeForTesting(blacklist_json, gpu_info); 178 manager->InitializeForTesting(blacklist_json, gpu_info);
179 179
180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
181 EXPECT_TRUE(reason.empty()); 181 EXPECT_TRUE(reason.empty());
182 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 182 if (manager->ShouldUseSwiftShader()) {
183 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); 183 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
184 EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL));
185 } else {
186 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
187 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL));
188 }
184 189
185 gpu_info.gl_vendor = "NVIDIA"; 190 gpu_info.gl_vendor = "NVIDIA";
186 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; 191 gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
187 manager->UpdateGpuInfo(gpu_info); 192 manager->UpdateGpuInfo(gpu_info);
188 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); 193 if (manager->ShouldUseSwiftShader()) {
189 EXPECT_FALSE(reason.empty()); 194 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
195 EXPECT_TRUE(reason.empty());
196 } else {
197 EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
198 EXPECT_FALSE(reason.empty());
199 }
190 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); 200 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
191 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); 201 if (manager->ShouldUseSwiftShader()) {
202 EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL));
203 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
204 } else {
205 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL));
206 EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
207 }
192 EXPECT_TRUE(manager->IsFeatureBlacklisted( 208 EXPECT_TRUE(manager->IsFeatureBlacklisted(
193 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 209 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
194 } 210 }
195 211
196 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { 212 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) {
197 // If a feature is allowed in preliminary step (browser side), but 213 // If a feature is allowed in preliminary step (browser side), but
198 // disabled when GPU process launches and collects full GPU info, 214 // disabled when GPU process launches and collects full GPU info,
199 // it's too late to let renderer know, so we basically block all GPU 215 // it's too late to let renderer know, so we basically block all GPU
200 // access, to be on the safe side. 216 // access, to be on the safe side.
201 ScopedGpuDataManagerImplPrivate manager; 217 ScopedGpuDataManagerImplPrivate manager;
(...skipping 25 matching lines...) Expand all
227 } 243 }
228 ); 244 );
229 245
230 gpu::GPUInfo gpu_info; 246 gpu::GPUInfo gpu_info;
231 gpu_info.gpu.vendor_id = 0x10de; 247 gpu_info.gpu.vendor_id = 0x10de;
232 gpu_info.gpu.device_id = 0x0640; 248 gpu_info.gpu.device_id = 0x0640;
233 manager->InitializeForTesting(blacklist_json, gpu_info); 249 manager->InitializeForTesting(blacklist_json, gpu_info);
234 250
235 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 251 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
236 EXPECT_TRUE(reason.empty()); 252 EXPECT_TRUE(reason.empty());
237 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 253 if (manager->ShouldUseSwiftShader()) {
254 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
255 } else {
256 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
257 }
238 EXPECT_TRUE(manager->IsFeatureBlacklisted( 258 EXPECT_TRUE(manager->IsFeatureBlacklisted(
239 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 259 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
240 260
241 gpu_info.gl_vendor = "NVIDIA"; 261 gpu_info.gl_vendor = "NVIDIA";
242 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; 262 gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
243 manager->UpdateGpuInfo(gpu_info); 263 manager->UpdateGpuInfo(gpu_info);
244 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 264 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
245 EXPECT_TRUE(reason.empty()); 265 EXPECT_TRUE(reason.empty());
246 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); 266 if (manager->ShouldUseSwiftShader()) {
267 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
268 } else {
269 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount());
270 }
247 EXPECT_TRUE(manager->IsFeatureBlacklisted( 271 EXPECT_TRUE(manager->IsFeatureBlacklisted(
248 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 272 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
249 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); 273 if (manager->ShouldUseSwiftShader()) {
274 EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL));
275 } else {
276 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL));
277 }
250 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); 278 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
251 } 279 }
252 280
253 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { 281 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) {
254 ScopedGpuDataManagerImplPrivate manager; 282 ScopedGpuDataManagerImplPrivate manager;
255 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 283 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
256 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 284 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
257 285
258 const std::string blacklist_json = LONG_STRING_CONST( 286 const std::string blacklist_json = LONG_STRING_CONST(
259 { 287 {
(...skipping 13 matching lines...) Expand all
273 } 301 }
274 ] 302 ]
275 } 303 }
276 ); 304 );
277 gpu::GPUInfo gpu_info; 305 gpu::GPUInfo gpu_info;
278 gpu_info.gpu.vendor_id = 0x10de; 306 gpu_info.gpu.vendor_id = 0x10de;
279 gpu_info.gpu.device_id = 0x0640; 307 gpu_info.gpu.device_id = 0x0640;
280 manager->InitializeForTesting(blacklist_json, gpu_info); 308 manager->InitializeForTesting(blacklist_json, gpu_info);
281 309
282 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 310 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
283 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 311 EXPECT_EQ(manager->ShouldUseSwiftShader() ? 2u : 1u,
312 manager->GetBlacklistedFeatureCount());
284 313
285 // Now assume gpu process launches and full GPU info is collected. 314 // Now assume gpu process launches and full GPU info is collected.
286 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; 315 gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
287 manager->UpdateGpuInfo(gpu_info); 316 manager->UpdateGpuInfo(gpu_info);
288 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 317 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
289 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 318 // Since SwiftShader was enabled by first gpu_info, UpdateGpuInfo
319 // should have failed and SwiftShader should still be active
320 EXPECT_EQ(manager->ShouldUseSwiftShader() ? 2u : 0u,
321 manager->GetBlacklistedFeatureCount());
290 } 322 }
291 323
292 TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) { 324 TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) {
293 ScopedGpuDataManagerImplPrivate manager; 325 ScopedGpuDataManagerImplPrivate manager;
294 manager->InitializeForTesting("", gpu::GPUInfo()); 326 manager->InitializeForTesting("", gpu::GPUInfo());
295 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 327 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
296 std::string reason; 328 std::string reason;
297 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 329 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
298 EXPECT_TRUE(reason.empty()); 330 EXPECT_TRUE(reason.empty());
299 331
300 manager->DisableHardwareAcceleration(); 332 manager->DisableHardwareAcceleration();
301 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); 333 if (manager->ShouldUseSwiftShader()) {
302 EXPECT_FALSE(reason.empty()); 334 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
303 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), 335 EXPECT_TRUE(reason.empty());
304 manager->GetBlacklistedFeatureCount()); 336 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
337 } else {
338 EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
339 EXPECT_FALSE(reason.empty());
340 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
341 manager->GetBlacklistedFeatureCount());
342 }
305 } 343 }
306 344
307 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) { 345 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) {
308 // Blacklist, then register SwiftShader. 346 // Blacklist, then register SwiftShader.
309 ScopedGpuDataManagerImplPrivate manager; 347 ScopedGpuDataManagerImplPrivate manager;
310 manager->InitializeForTesting("", gpu::GPUInfo()); 348 manager->InitializeForTesting("", gpu::GPUInfo());
311 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 349 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
312 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 350 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
313 EXPECT_FALSE(manager->ShouldUseSwiftShader()); 351 EXPECT_FALSE(manager->ShouldUseSwiftShader());
314 352
315 manager->DisableHardwareAcceleration(); 353 manager->DisableHardwareAcceleration();
316 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); 354 if (manager->ShouldUseSwiftShader()) {
317 EXPECT_FALSE(manager->ShouldUseSwiftShader()); 355 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
318 356 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
319 // If SwiftShader is enabled, even if we blacklist GPU, 357 } else {
320 // GPU process is still allowed. 358 EXPECT_FALSE(manager->GpuAccessAllowed(NULL));
321 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); 359 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
322 manager->RegisterSwiftShaderPath(test_path); 360 manager->GetBlacklistedFeatureCount());
323 EXPECT_TRUE(manager->ShouldUseSwiftShader()); 361 }
324 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
325 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
326 EXPECT_TRUE(manager->IsFeatureBlacklisted( 362 EXPECT_TRUE(manager->IsFeatureBlacklisted(
327 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 363 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
364 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
328 } 365 }
329 366
330 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { 367 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) {
331 // Register SwiftShader, then blacklist. 368 // Register SwiftShader, then blacklist.
332 ScopedGpuDataManagerImplPrivate manager; 369 ScopedGpuDataManagerImplPrivate manager;
333 manager->InitializeForTesting("", gpu::GPUInfo()); 370 manager->InitializeForTesting("", gpu::GPUInfo());
334 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 371 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
335 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 372 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
336 EXPECT_FALSE(manager->ShouldUseSwiftShader()); 373 EXPECT_FALSE(manager->ShouldUseSwiftShader());
337 374
338 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath"));
339 manager->RegisterSwiftShaderPath(test_path);
340 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
341 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
342 EXPECT_FALSE(manager->ShouldUseSwiftShader());
343
344 manager->DisableHardwareAcceleration(); 375 manager->DisableHardwareAcceleration();
345 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 376 if (manager->ShouldUseSwiftShader()) {
346 EXPECT_TRUE(manager->ShouldUseSwiftShader()); 377 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
347 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 378 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
379 } else {
380 EXPECT_FALSE(manager->GpuAccessAllowed(NULL));
381 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
382 manager->GetBlacklistedFeatureCount());
383 }
348 EXPECT_TRUE(manager->IsFeatureBlacklisted( 384 EXPECT_TRUE(manager->IsFeatureBlacklisted(
349 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 385 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
386 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
350 } 387 }
351 388
352 TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) { 389 TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) {
353 ScopedGpuDataManagerImpl manager; 390 ScopedGpuDataManagerImpl manager;
354 391
355 TestObserver observer; 392 TestObserver observer;
356 manager->AddObserver(&observer); 393 manager->AddObserver(&observer);
357 394
358 { 395 {
359 base::RunLoop run_loop; 396 base::RunLoop run_loop;
360 run_loop.RunUntilIdle(); 397 run_loop.RunUntilIdle();
361 } 398 }
362 EXPECT_FALSE(observer.gpu_info_updated()); 399 EXPECT_FALSE(observer.gpu_info_updated());
363 400
364 gpu::GPUInfo gpu_info; 401 gpu::GPUInfo gpu_info;
365 manager->UpdateGpuInfo(gpu_info); 402 manager->UpdateGpuInfo(gpu_info);
366 { 403 {
367 base::RunLoop run_loop; 404 base::RunLoop run_loop;
368 run_loop.RunUntilIdle(); 405 run_loop.RunUntilIdle();
369 } 406 }
370 EXPECT_TRUE(observer.gpu_info_updated()); 407 EXPECT_TRUE(observer.gpu_info_updated());
371 } 408 }
372 409
373 TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) { 410 TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) {
374 ScopedGpuDataManagerImpl manager; 411 ScopedGpuDataManagerImpl manager;
375 manager->InitializeForTesting("", gpu::GPUInfo()); 412 manager->InitializeForTesting("", gpu::GPUInfo());
376 413
377 manager->DisableHardwareAcceleration(); 414 manager->DisableHardwareAcceleration();
378 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); 415 if (manager->ShouldUseSwiftShader()) {
379 manager->RegisterSwiftShaderPath(test_path); 416 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
380 EXPECT_TRUE(manager->ShouldUseSwiftShader()); 417 } else {
381 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 418 EXPECT_FALSE(manager->GpuAccessAllowed(NULL));
419 }
382 420
383 { 421 {
384 base::RunLoop run_loop; 422 base::RunLoop run_loop;
385 run_loop.RunUntilIdle(); 423 run_loop.RunUntilIdle();
386 } 424 }
387 425
388 TestObserver observer; 426 TestObserver observer;
389 manager->AddObserver(&observer); 427 manager->AddObserver(&observer);
390 { 428 {
391 base::RunLoop run_loop; 429 base::RunLoop run_loop;
392 run_loop.RunUntilIdle(); 430 run_loop.RunUntilIdle();
393 } 431 }
394 EXPECT_FALSE(observer.gpu_info_updated()); 432 EXPECT_FALSE(observer.gpu_info_updated());
395 433
396 gpu::GPUInfo gpu_info; 434 gpu::GPUInfo gpu_info;
397 manager->UpdateGpuInfo(gpu_info); 435 manager->UpdateGpuInfo(gpu_info);
398 { 436 {
399 base::RunLoop run_loop; 437 base::RunLoop run_loop;
400 run_loop.RunUntilIdle(); 438 run_loop.RunUntilIdle();
401 } 439 }
402 EXPECT_FALSE(observer.gpu_info_updated()); 440 if (manager->ShouldUseSwiftShader()) {
441 // Once SwiftShader is enabled, the gpu info can no longer be updated
442 EXPECT_FALSE(observer.gpu_info_updated());
443 } else {
444 EXPECT_TRUE(observer.gpu_info_updated());
445 }
403 } 446 }
404 447
405 TEST_F(GpuDataManagerImplPrivateTest, GPUVideoMemoryUsageStatsUpdate) { 448 TEST_F(GpuDataManagerImplPrivateTest, GPUVideoMemoryUsageStatsUpdate) {
406 ScopedGpuDataManagerImpl manager; 449 ScopedGpuDataManagerImpl manager;
407 450
408 TestObserver observer; 451 TestObserver observer;
409 manager->AddObserver(&observer); 452 manager->AddObserver(&observer);
410 453
411 { 454 {
412 base::RunLoop run_loop; 455 base::RunLoop run_loop;
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } 784 }
742 ] 785 ]
743 } 786 }
744 ); 787 );
745 788
746 gpu::GPUInfo gpu_info; 789 gpu::GPUInfo gpu_info;
747 gpu_info.gpu.vendor_id = 0x10de; 790 gpu_info.gpu.vendor_id = 0x10de;
748 gpu_info.gpu.device_id = 0x0640; 791 gpu_info.gpu.device_id = 0x0640;
749 manager->InitializeForTesting(blacklist_json, gpu_info); 792 manager->InitializeForTesting(blacklist_json, gpu_info);
750 793
751 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), 794 if (manager->ShouldUseSwiftShader()) {
752 manager->GetBlacklistedFeatureCount()); 795 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
753 // TODO(zmo): remove the Linux specific behavior once we fix 796 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
754 // crbug.com/238466. 797 EXPECT_TRUE(reason.empty());
755 #if defined(OS_LINUX) 798 } else {
756 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 799 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
757 EXPECT_TRUE(reason.empty()); 800 manager->GetBlacklistedFeatureCount());
758 #else 801 }
759 EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
760 EXPECT_FALSE(reason.empty());
761 #endif
762 } 802 }
763 803
764 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { 804 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
765 ScopedGpuDataManagerImpl manager; 805 ScopedGpuDataManagerImpl manager;
766 806
767 const std::string blacklist_json = LONG_STRING_CONST( 807 const std::string blacklist_json = LONG_STRING_CONST(
768 { 808 {
769 "name": "gpu blacklist", 809 "name": "gpu blacklist",
770 "version": "0.1", 810 "version": "0.1",
771 "entries": [ 811 "entries": [
(...skipping 17 matching lines...) Expand all
789 gpu::GPUInfo::GPUDevice intel_gpu; 829 gpu::GPUInfo::GPUDevice intel_gpu;
790 intel_gpu.vendor_id = 0x8086; 830 intel_gpu.vendor_id = 0x8086;
791 intel_gpu.device_id = 0x04a1; 831 intel_gpu.device_id = 0x04a1;
792 intel_gpu.active = true; 832 intel_gpu.active = true;
793 gpu_info.secondary_gpus.push_back(intel_gpu); 833 gpu_info.secondary_gpus.push_back(intel_gpu);
794 834
795 manager->InitializeForTesting(blacklist_json, gpu_info); 835 manager->InitializeForTesting(blacklist_json, gpu_info);
796 TestObserver observer; 836 TestObserver observer;
797 manager->AddObserver(&observer); 837 manager->AddObserver(&observer);
798 838
799 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 839 if (manager->ShouldUseSwiftShader()) {
840 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
841 } else {
842 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
843 }
800 844
801 // Update with the same Intel GPU active. 845 // Update with the same Intel GPU active.
802 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1)); 846 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1));
803 { 847 {
804 base::RunLoop run_loop; 848 base::RunLoop run_loop;
805 run_loop.RunUntilIdle(); 849 run_loop.RunUntilIdle();
806 } 850 }
807 EXPECT_FALSE(observer.gpu_info_updated()); 851 EXPECT_FALSE(observer.gpu_info_updated());
808 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 852 if (manager->ShouldUseSwiftShader()) {
853 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
854 } else {
855 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
856 }
809 857
810 // Set NVIDIA GPU to be active. 858 // Set NVIDIA GPU to be active.
811 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); 859 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640));
812 { 860 {
813 base::RunLoop run_loop; 861 base::RunLoop run_loop;
814 run_loop.RunUntilIdle(); 862 run_loop.RunUntilIdle();
815 } 863 }
816 EXPECT_TRUE(observer.gpu_info_updated()); 864 EXPECT_TRUE(observer.gpu_info_updated());
817 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 865 if (manager->ShouldUseSwiftShader()) {
866 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
867 } else {
868 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
869 }
818 870
819 observer.Reset(); 871 observer.Reset();
820 EXPECT_FALSE(observer.gpu_info_updated()); 872 EXPECT_FALSE(observer.gpu_info_updated());
821 873
822 // Update with the same NVIDIA GPU active. 874 // Update with the same NVIDIA GPU active.
823 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640)); 875 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640));
824 { 876 {
825 base::RunLoop run_loop; 877 base::RunLoop run_loop;
826 run_loop.RunUntilIdle(); 878 run_loop.RunUntilIdle();
827 } 879 }
828 EXPECT_FALSE(observer.gpu_info_updated()); 880 EXPECT_FALSE(observer.gpu_info_updated());
829 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 881 if (manager->ShouldUseSwiftShader()) {
882 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
883 } else {
884 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
885 }
830 886
831 // Set Intel GPU to be active. 887 // Set Intel GPU to be active.
832 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); 888 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1));
833 { 889 {
834 base::RunLoop run_loop; 890 base::RunLoop run_loop;
835 run_loop.RunUntilIdle(); 891 run_loop.RunUntilIdle();
836 } 892 }
837 EXPECT_TRUE(observer.gpu_info_updated()); 893 EXPECT_TRUE(observer.gpu_info_updated());
838 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 894 if (manager->ShouldUseSwiftShader()) {
895 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
896 } else {
897 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
898 }
839 } 899 }
840 900
841 } // namespace content 901 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698