OLD | NEW |
---|---|
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 gpu_info.gl_vendor = "NVIDIA"; | 178 gpu_info.gl_vendor = "NVIDIA"; |
179 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 179 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
180 manager->UpdateGpuInfo(gpu_info); | 180 manager->UpdateGpuInfo(gpu_info); |
181 if (manager->ShouldUseSwiftShader()) { | 181 if (manager->ShouldUseSwiftShader()) { |
182 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 182 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
183 EXPECT_TRUE(reason.empty()); | 183 EXPECT_TRUE(reason.empty()); |
184 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 184 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
185 manager->GetBlacklistedFeatureCount()); | 185 manager->GetBlacklistedFeatureCount()); |
186 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); | 186 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
187 } else { | 187 } else { |
188 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); | 188 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
189 EXPECT_FALSE(reason.empty()); | 189 EXPECT_TRUE(reason.empty()); |
190 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); | 190 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
191 EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); | 191 EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
192 } | 192 } |
193 EXPECT_TRUE( | 193 EXPECT_TRUE( |
194 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 194 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
195 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 195 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
196 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 196 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
197 } | 197 } |
198 | 198 |
199 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { | 199 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 }; | 563 }; |
564 const gpu::GpuControlListData kData("1.0", 1, kEntries); | 564 const gpu::GpuControlListData kData("1.0", 1, kEntries); |
565 | 565 |
566 gpu::GPUInfo gpu_info; | 566 gpu::GPUInfo gpu_info; |
567 gpu_info.gpu.vendor_id = 0x8086; | 567 gpu_info.gpu.vendor_id = 0x8086; |
568 gpu_info.gpu.device_id = 0x0042; | 568 gpu_info.gpu.device_id = 0x0042; |
569 manager->InitializeForTesting(kData, gpu_info); | 569 manager->InitializeForTesting(kData, gpu_info); |
570 | 570 |
571 // Not enough GPUInfo. | 571 // Not enough GPUInfo. |
572 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 572 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
573 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 573 if (manager->ShouldUseSwiftShader()) { |
574 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | |
575 manager->GetBlacklistedFeatureCount()); | |
576 } else { | |
577 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | |
578 } | |
574 | 579 |
575 // Now assume browser gets GL strings from local state. | 580 // Now assume browser gets GL strings from local state. |
576 // The entry applies, blacklist more features than from the preliminary step. | 581 // The entry applies, blacklist more features than from the preliminary step. |
577 // However, GPU process is not blocked because this is all browser side and | 582 // However, GPU process is not blocked because this is all browser side and |
578 // happens before renderer launching. | 583 // happens before renderer launching. |
579 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 584 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
580 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 585 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
581 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 586 if (manager->ShouldUseSwiftShader()) { |
587 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | |
588 manager->GetBlacklistedFeatureCount()); | |
589 } else { | |
590 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | |
591 } | |
582 EXPECT_TRUE( | 592 EXPECT_TRUE( |
583 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 593 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
584 } | 594 } |
585 | 595 |
586 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { | 596 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { |
587 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 597 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
588 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 598 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
589 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 599 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
590 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; | 600 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; |
591 | 601 |
(...skipping 12 matching lines...) Expand all Loading... | |
604 gpu_info.gpu.device_id = 0x0042; | 614 gpu_info.gpu.device_id = 0x0042; |
605 gpu_info.gl_vendor = kGLVendorMesa; | 615 gpu_info.gl_vendor = kGLVendorMesa; |
606 gpu_info.gl_renderer = kGLRendererMesa; | 616 gpu_info.gl_renderer = kGLRendererMesa; |
607 gpu_info.gl_version = kGLVersionMesa801; | 617 gpu_info.gl_version = kGLVersionMesa801; |
608 gpu_info.driver_vendor = "Mesa"; | 618 gpu_info.driver_vendor = "Mesa"; |
609 gpu_info.driver_version = "8.0.1"; | 619 gpu_info.driver_version = "8.0.1"; |
610 manager->InitializeForTesting(kData, gpu_info); | 620 manager->InitializeForTesting(kData, gpu_info); |
611 | 621 |
612 // Full GPUInfo, the entry applies. | 622 // Full GPUInfo, the entry applies. |
613 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 623 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
614 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 624 if (manager->ShouldUseSwiftShader()) { |
625 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | |
626 manager->GetBlacklistedFeatureCount()); | |
627 } else { | |
628 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | |
629 } | |
615 EXPECT_TRUE( | 630 EXPECT_TRUE( |
616 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 631 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
617 | 632 |
618 // Now assume browser gets GL strings from local state. | 633 // Now assume browser gets GL strings from local state. |
619 // SetGLStrings() has no effects because GPUInfo already got these strings. | 634 // SetGLStrings() has no effects because GPUInfo already got these strings. |
620 // (Otherwise the entry should not apply.) | 635 // (Otherwise the entry should not apply.) |
621 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); | 636 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); |
622 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 637 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
623 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 638 if (manager->ShouldUseSwiftShader()) { |
639 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | |
640 manager->GetBlacklistedFeatureCount()); | |
641 } else { | |
642 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | |
643 } | |
624 EXPECT_TRUE( | 644 EXPECT_TRUE( |
625 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 645 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
626 } | 646 } |
627 | 647 |
628 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { | 648 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { |
629 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 649 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
630 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 650 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
631 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 651 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
632 | 652 |
633 ScopedGpuDataManagerImplPrivate manager; | 653 ScopedGpuDataManagerImplPrivate manager; |
(...skipping 10 matching lines...) Expand all Loading... | |
644 | 664 |
645 // Assume browser gets GL strings from local state. | 665 // Assume browser gets GL strings from local state. |
646 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 666 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
647 | 667 |
648 gpu::GPUInfo gpu_info; | 668 gpu::GPUInfo gpu_info; |
649 gpu_info.gpu.vendor_id = 0x8086; | 669 gpu_info.gpu.vendor_id = 0x8086; |
650 gpu_info.gpu.device_id = 0x0042; | 670 gpu_info.gpu.device_id = 0x0042; |
651 manager->InitializeForTesting(kData, gpu_info); | 671 manager->InitializeForTesting(kData, gpu_info); |
652 | 672 |
653 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 673 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
654 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 674 if (manager->ShouldUseSwiftShader()) { |
675 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | |
676 manager->GetBlacklistedFeatureCount()); | |
677 } else { | |
678 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | |
679 } | |
680 | |
655 EXPECT_TRUE( | 681 EXPECT_TRUE( |
656 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 682 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
657 } | 683 } |
658 #endif // OS_LINUX | 684 #endif // OS_LINUX |
659 | 685 |
660 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { | 686 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { |
661 ScopedGpuDataManagerImplPrivate manager; | 687 ScopedGpuDataManagerImplPrivate manager; |
662 manager->gpu_driver_bugs_.insert(5); | 688 manager->gpu_driver_bugs_.insert(5); |
663 | 689 |
664 base::CommandLine command_line(0, NULL); | 690 base::CommandLine command_line(0, NULL); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 764 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
739 manager->GetBlacklistedFeatureCount()); | 765 manager->GetBlacklistedFeatureCount()); |
740 | 766 |
741 // Update to previous Intel GPU. | 767 // Update to previous Intel GPU. |
742 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 768 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
743 { | 769 { |
744 base::RunLoop run_loop; | 770 base::RunLoop run_loop; |
745 run_loop.RunUntilIdle(); | 771 run_loop.RunUntilIdle(); |
746 } | 772 } |
747 EXPECT_TRUE(observer.gpu_info_updated()); | 773 EXPECT_TRUE(observer.gpu_info_updated()); |
748 | |
749 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 774 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
750 manager->GetBlacklistedFeatureCount()); | 775 manager->GetBlacklistedFeatureCount()); |
751 } else { | 776 } else { |
752 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 777 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
753 | 778 |
754 // Update with the same Intel GPU active. | 779 // Update to previous Intel GPU. |
755 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 780 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
756 { | 781 { |
757 base::RunLoop run_loop; | 782 base::RunLoop run_loop; |
758 run_loop.RunUntilIdle(); | 783 run_loop.RunUntilIdle(); |
759 } | 784 } |
760 EXPECT_FALSE(observer.gpu_info_updated()); | 785 EXPECT_FALSE(observer.gpu_info_updated()); |
761 | |
762 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 786 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
763 } | 787 } |
764 | 788 |
765 // Set NVIDIA GPU to be active. | 789 // Set NVIDIA GPU to be active. |
766 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); | 790 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); |
767 { | 791 { |
768 base::RunLoop run_loop; | 792 base::RunLoop run_loop; |
769 run_loop.RunUntilIdle(); | 793 run_loop.RunUntilIdle(); |
770 } | 794 } |
771 EXPECT_TRUE(observer.gpu_info_updated()); | 795 EXPECT_TRUE(observer.gpu_info_updated()); |
772 if (manager->ShouldUseSwiftShader()) { | 796 if (manager->ShouldUseSwiftShader()) { |
773 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 797 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
774 manager->GetBlacklistedFeatureCount()); | 798 manager->GetBlacklistedFeatureCount()); |
775 } else { | 799 } else { |
776 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 800 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
777 } | 801 } |
778 | 802 |
779 observer.Reset(); | 803 observer.Reset(); |
780 EXPECT_FALSE(observer.gpu_info_updated()); | 804 EXPECT_FALSE(observer.gpu_info_updated()); |
781 | 805 |
806 // Update to previous NVIDIA GPU. | |
807 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640)); | |
808 { | |
809 base::RunLoop run_loop; | |
810 run_loop.RunUntilIdle(); | |
811 } | |
812 EXPECT_FALSE(observer.gpu_info_updated()); | |
Ken Russell (switch to Gerrit)
2017/04/11 22:03:45
It's a little confusing to me that the EXPECT_TRUE
| |
813 | |
782 if (manager->ShouldUseSwiftShader()) { | 814 if (manager->ShouldUseSwiftShader()) { |
783 // Update to previous NVIDIA GPU. | |
784 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); | |
785 { | |
786 base::RunLoop run_loop; | |
787 run_loop.RunUntilIdle(); | |
788 } | |
789 EXPECT_TRUE(observer.gpu_info_updated()); | |
790 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 815 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
791 manager->GetBlacklistedFeatureCount()); | 816 manager->GetBlacklistedFeatureCount()); |
792 } else { | 817 } else { |
793 // Update with the same NVIDIA GPU active. | |
794 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640)); | |
795 { | |
796 base::RunLoop run_loop; | |
797 run_loop.RunUntilIdle(); | |
798 } | |
799 EXPECT_FALSE(observer.gpu_info_updated()); | |
800 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 818 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
801 } | 819 } |
802 | 820 |
803 // Set Intel GPU to be active. | 821 // Set Intel GPU to be active. |
804 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 822 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
805 { | 823 { |
806 base::RunLoop run_loop; | 824 base::RunLoop run_loop; |
807 run_loop.RunUntilIdle(); | 825 run_loop.RunUntilIdle(); |
808 } | 826 } |
809 EXPECT_TRUE(observer.gpu_info_updated()); | 827 EXPECT_TRUE(observer.gpu_info_updated()); |
810 if (manager->ShouldUseSwiftShader()) { | 828 if (manager->ShouldUseSwiftShader()) { |
811 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 829 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
812 manager->GetBlacklistedFeatureCount()); | 830 manager->GetBlacklistedFeatureCount()); |
813 } else { | 831 } else { |
814 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 832 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
815 } | 833 } |
816 } | 834 } |
817 | 835 |
818 } // namespace content | 836 } // namespace content |
OLD | NEW |