Index: content/browser/gpu/gpu_data_manager_impl_private_unittest.cc |
diff --git a/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc b/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc |
index 880a83fe77f85d13a6bc49778cb7ce6e6645addc..b67fda50b035cacc55f7a3e4ad66f306952d86f3 100644 |
--- a/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc |
+++ b/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc |
@@ -17,6 +17,7 @@ |
#include "gpu/config/gpu_switches.h" |
#include "gpu/ipc/common/memory_stats.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#include "ui/gl/gl_features.h" |
#include "url/gurl.h" |
#if defined(OS_WIN) |
@@ -179,16 +180,30 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklisting) { |
EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
EXPECT_TRUE(reason.empty()); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+ EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); |
+#else |
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); |
+#endif |
gpu_info.gl_vendor = "NVIDIA"; |
gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
manager->UpdateGpuInfo(gpu_info); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
+ EXPECT_TRUE(reason.empty()); |
+#else |
EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
EXPECT_FALSE(reason.empty()); |
+#endif |
EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
- EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
+#else |
+ EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
+#endif |
EXPECT_TRUE(manager->IsFeatureBlacklisted( |
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
} |
@@ -234,7 +249,11 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { |
EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
EXPECT_TRUE(reason.empty()); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
+#endif |
EXPECT_TRUE(manager->IsFeatureBlacklisted( |
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
@@ -243,10 +262,20 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { |
manager->UpdateGpuInfo(gpu_info); |
EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
EXPECT_TRUE(reason.empty()); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_TRUE(manager->ShouldUseSwiftShader()); |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
+ EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); |
+#endif |
EXPECT_TRUE(manager->IsFeatureBlacklisted( |
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); |
+#else |
EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); |
+#endif |
EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
} |
@@ -280,7 +309,11 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { |
manager->InitializeForTesting(blacklist_json, gpu_info); |
EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
+#endif |
// Now assume gpu process launches and full GPU info is collected. |
gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
@@ -298,10 +331,17 @@ TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) { |
EXPECT_TRUE(reason.empty()); |
manager->DisableHardwareAcceleration(); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_TRUE(manager->ShouldUseSwiftShader()); |
+ EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
+ EXPECT_TRUE(reason.empty()); |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
+ EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
EXPECT_FALSE(reason.empty()); |
- EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
- manager->GetBlacklistedFeatureCount()); |
+ EXPECT_EQ(12u, manager->GetBlacklistedFeatureCount()); |
+#endif |
} |
TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) { |
@@ -313,18 +353,18 @@ TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) { |
EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
manager->DisableHardwareAcceleration(); |
- EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); |
- EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
- |
- // If SwiftShader is enabled, even if we blacklist GPU, |
- // GPU process is still allowed. |
- const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
- manager->RegisterSwiftShaderPath(test_path); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
EXPECT_TRUE(manager->ShouldUseSwiftShader()); |
EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
+ EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
+ EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); |
+ EXPECT_EQ(12u, manager->GetBlacklistedFeatureCount()); |
+#endif |
EXPECT_TRUE(manager->IsFeatureBlacklisted( |
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
+ EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
} |
TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { |
@@ -335,18 +375,19 @@ TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { |
EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
- const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
- manager->RegisterSwiftShaderPath(test_path); |
- EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
- EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
- EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
- |
manager->DisableHardwareAcceleration(); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
EXPECT_TRUE(manager->ShouldUseSwiftShader()); |
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
+ EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); |
+ EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
+ EXPECT_EQ(12u, manager->GetBlacklistedFeatureCount()); |
+#endif |
EXPECT_TRUE(manager->IsFeatureBlacklisted( |
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
+ EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
} |
TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) { |
@@ -375,10 +416,13 @@ TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) { |
manager->InitializeForTesting("", gpu::GPUInfo()); |
manager->DisableHardwareAcceleration(); |
- const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
- manager->RegisterSwiftShaderPath(test_path); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
EXPECT_TRUE(manager->ShouldUseSwiftShader()); |
EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
+#else |
+ EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
+ EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); |
+#endif |
{ |
base::RunLoop run_loop; |
@@ -399,7 +443,7 @@ TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) { |
base::RunLoop run_loop; |
run_loop.RunUntilIdle(); |
} |
- EXPECT_FALSE(observer.gpu_info_updated()); |
+ EXPECT_TRUE(observer.gpu_info_updated()); |
} |
TEST_F(GpuDataManagerImplPrivateTest, GPUVideoMemoryUsageStatsUpdate) { |
@@ -748,16 +792,12 @@ TEST_F(GpuDataManagerImplPrivateTest, BlacklistAllFeatures) { |
gpu_info.gpu.device_id = 0x0640; |
manager->InitializeForTesting(blacklist_json, gpu_info); |
- EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
- manager->GetBlacklistedFeatureCount()); |
- // TODO(zmo): remove the Linux specific behavior once we fix |
- // crbug.com/238466. |
-#if defined(OS_LINUX) |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
EXPECT_TRUE(reason.empty()); |
#else |
- EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
- EXPECT_FALSE(reason.empty()); |
+ EXPECT_EQ(12u, manager->GetBlacklistedFeatureCount()); |
#endif |
} |
@@ -796,7 +836,11 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { |
TestObserver observer; |
manager->AddObserver(&observer); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
+#endif |
// Update with the same Intel GPU active. |
EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
@@ -805,7 +849,11 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { |
run_loop.RunUntilIdle(); |
} |
EXPECT_FALSE(observer.gpu_info_updated()); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
+#endif |
// Set NVIDIA GPU to be active. |
EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); |
@@ -835,7 +883,11 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { |
run_loop.RunUntilIdle(); |
} |
EXPECT_TRUE(observer.gpu_info_updated()); |
+#if BUILDFLAG(ENABLE_SWIFTSHADER) |
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
+#else |
EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
+#endif |
} |
} // namespace content |