| 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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 intel_gpu.active = true; | 830 intel_gpu.active = true; |
| 831 gpu_info.secondary_gpus.push_back(intel_gpu); | 831 gpu_info.secondary_gpus.push_back(intel_gpu); |
| 832 | 832 |
| 833 manager->InitializeForTesting(blacklist_json, gpu_info); | 833 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 834 TestObserver observer; | 834 TestObserver observer; |
| 835 manager->AddObserver(&observer); | 835 manager->AddObserver(&observer); |
| 836 | 836 |
| 837 if (manager->ShouldUseSwiftShader()) { | 837 if (manager->ShouldUseSwiftShader()) { |
| 838 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 838 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 839 manager->GetBlacklistedFeatureCount()); | 839 manager->GetBlacklistedFeatureCount()); |
| 840 |
| 841 // Update to previous Intel GPU. |
| 842 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
| 843 { |
| 844 base::RunLoop run_loop; |
| 845 run_loop.RunUntilIdle(); |
| 846 } |
| 847 EXPECT_TRUE(observer.gpu_info_updated()); |
| 848 |
| 849 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 850 manager->GetBlacklistedFeatureCount()); |
| 840 } else { | 851 } else { |
| 841 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 852 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 842 } | |
| 843 | 853 |
| 844 // Update with the same Intel GPU active. | 854 // Update with the same Intel GPU active. |
| 845 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 855 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
| 846 { | 856 { |
| 847 base::RunLoop run_loop; | 857 base::RunLoop run_loop; |
| 848 run_loop.RunUntilIdle(); | 858 run_loop.RunUntilIdle(); |
| 849 } | 859 } |
| 850 EXPECT_FALSE(observer.gpu_info_updated()); | 860 EXPECT_FALSE(observer.gpu_info_updated()); |
| 851 if (manager->ShouldUseSwiftShader()) { | 861 |
| 852 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | |
| 853 manager->GetBlacklistedFeatureCount()); | |
| 854 } else { | |
| 855 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 862 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 856 } | 863 } |
| 857 | 864 |
| 858 // Set NVIDIA GPU to be active. | 865 // Set NVIDIA GPU to be active. |
| 859 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); | 866 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); |
| 860 { | 867 { |
| 861 base::RunLoop run_loop; | 868 base::RunLoop run_loop; |
| 862 run_loop.RunUntilIdle(); | 869 run_loop.RunUntilIdle(); |
| 863 } | 870 } |
| 864 EXPECT_TRUE(observer.gpu_info_updated()); | 871 EXPECT_TRUE(observer.gpu_info_updated()); |
| 865 if (manager->ShouldUseSwiftShader()) { | 872 if (manager->ShouldUseSwiftShader()) { |
| 866 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 873 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 867 manager->GetBlacklistedFeatureCount()); | 874 manager->GetBlacklistedFeatureCount()); |
| 868 } else { | 875 } else { |
| 869 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 876 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 870 } | 877 } |
| 871 | 878 |
| 872 observer.Reset(); | 879 observer.Reset(); |
| 873 EXPECT_FALSE(observer.gpu_info_updated()); | 880 EXPECT_FALSE(observer.gpu_info_updated()); |
| 874 | 881 |
| 875 // Update with the same NVIDIA GPU active. | |
| 876 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640)); | |
| 877 { | |
| 878 base::RunLoop run_loop; | |
| 879 run_loop.RunUntilIdle(); | |
| 880 } | |
| 881 EXPECT_FALSE(observer.gpu_info_updated()); | |
| 882 if (manager->ShouldUseSwiftShader()) { | 882 if (manager->ShouldUseSwiftShader()) { |
| 883 // Update to previous NVIDIA GPU. |
| 884 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); |
| 885 { |
| 886 base::RunLoop run_loop; |
| 887 run_loop.RunUntilIdle(); |
| 888 } |
| 889 EXPECT_TRUE(observer.gpu_info_updated()); |
| 883 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 890 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 884 manager->GetBlacklistedFeatureCount()); | 891 manager->GetBlacklistedFeatureCount()); |
| 885 } else { | 892 } else { |
| 893 // Update with the same NVIDIA GPU active. |
| 894 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640)); |
| 895 { |
| 896 base::RunLoop run_loop; |
| 897 run_loop.RunUntilIdle(); |
| 898 } |
| 899 EXPECT_FALSE(observer.gpu_info_updated()); |
| 886 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 900 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 887 } | 901 } |
| 888 | 902 |
| 889 // Set Intel GPU to be active. | 903 // Set Intel GPU to be active. |
| 890 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 904 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
| 891 { | 905 { |
| 892 base::RunLoop run_loop; | 906 base::RunLoop run_loop; |
| 893 run_loop.RunUntilIdle(); | 907 run_loop.RunUntilIdle(); |
| 894 } | 908 } |
| 895 EXPECT_TRUE(observer.gpu_info_updated()); | 909 EXPECT_TRUE(observer.gpu_info_updated()); |
| 896 if (manager->ShouldUseSwiftShader()) { | 910 if (manager->ShouldUseSwiftShader()) { |
| 897 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 911 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 898 manager->GetBlacklistedFeatureCount()); | 912 manager->GetBlacklistedFeatureCount()); |
| 899 } else { | 913 } else { |
| 900 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 914 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 901 } | 915 } |
| 902 } | 916 } |
| 903 | 917 |
| 904 } // namespace content | 918 } // namespace content |
| OLD | NEW |