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

Unified Diff: content/browser/gpu/gpu_data_manager_impl_private_unittest.cc

Issue 2715563002: Moving SwiftShader from component to bundled library (Closed)
Patch Set: Update past extension test fixes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl_private.cc ('k') | content/public/browser/gpu_data_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7e813da4023e64c5614841f78236d266dcf6d7fd..0a239f3dc842c3d6c51774f836feed73e4989856 100644
--- a/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc
+++ b/content/browser/gpu/gpu_data_manager_impl_private_unittest.cc
@@ -179,16 +179,30 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklisting) {
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ }
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
gpu_info.gl_vendor = "NVIDIA";
gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
manager->UpdateGpuInfo(gpu_info);
- EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
- EXPECT_FALSE(reason.empty());
- EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
+ EXPECT_TRUE(reason.empty());
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
+ } else {
+ EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
+ EXPECT_FALSE(reason.empty());
+ EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
+ EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
+ }
EXPECT_TRUE(
manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
EXPECT_TRUE(manager->IsFeatureBlacklisted(
@@ -236,7 +250,12 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) {
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ }
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
@@ -245,7 +264,12 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) {
manager->UpdateGpuInfo(gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
EXPECT_TRUE(reason.empty());
- EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount());
+ }
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
EXPECT_TRUE(
@@ -283,13 +307,21 @@ TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) {
manager->InitializeForTesting(blacklist_json, gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ EXPECT_EQ(manager->ShouldUseSwiftShader()
+ ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES)
+ : 1u,
+ manager->GetBlacklistedFeatureCount());
// Now assume gpu process launches and full GPU info is collected.
gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
manager->UpdateGpuInfo(gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
- EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
+ // Since SwiftShader was enabled by first gpu_info, UpdateGpuInfo
+ // should have failed and SwiftShader should still be active
+ EXPECT_EQ(manager->ShouldUseSwiftShader()
+ ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES)
+ : 0u,
+ manager->GetBlacklistedFeatureCount());
}
TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) {
@@ -301,8 +333,13 @@ TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) {
EXPECT_TRUE(reason.empty());
manager->DisableHardwareAcceleration();
- EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
- EXPECT_FALSE(reason.empty());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
+ EXPECT_TRUE(reason.empty());
+ } else {
+ EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
+ EXPECT_FALSE(reason.empty());
+ }
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
}
@@ -316,19 +353,12 @@ 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);
- EXPECT_TRUE(manager->ShouldUseSwiftShader());
- EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
+ EXPECT_EQ(manager->ShouldUseSwiftShader(), manager->GpuAccessAllowed(NULL));
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
+ EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
}
TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) {
@@ -339,19 +369,17 @@ 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();
- EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
- EXPECT_TRUE(manager->ShouldUseSwiftShader());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
+ } else {
+ EXPECT_FALSE(manager->GpuAccessAllowed(NULL));
+ }
EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
manager->GetBlacklistedFeatureCount());
EXPECT_TRUE(manager->IsFeatureBlacklisted(
gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
+ EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
}
TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) {
@@ -380,10 +408,11 @@ TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) {
manager->InitializeForTesting("", gpu::GPUInfo());
manager->DisableHardwareAcceleration();
- const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath"));
- manager->RegisterSwiftShaderPath(test_path);
- EXPECT_TRUE(manager->ShouldUseSwiftShader());
- EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
+ } else {
+ EXPECT_FALSE(manager->GpuAccessAllowed(NULL));
+ }
{
base::RunLoop run_loop;
@@ -404,7 +433,12 @@ TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) {
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
- EXPECT_FALSE(observer.gpu_info_updated());
+ if (manager->ShouldUseSwiftShader()) {
+ // Once SwiftShader is enabled, the gpu info can no longer be updated
+ EXPECT_FALSE(observer.gpu_info_updated());
+ } else {
+ EXPECT_TRUE(observer.gpu_info_updated());
+ }
}
TEST_F(GpuDataManagerImplPrivateTest, GPUVideoMemoryUsageStatsUpdate) {
@@ -759,15 +793,10 @@ TEST_F(GpuDataManagerImplPrivateTest, BlacklistAllFeatures) {
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)
- EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
- EXPECT_TRUE(reason.empty());
-#else
- EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
- EXPECT_FALSE(reason.empty());
-#endif
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
+ EXPECT_TRUE(reason.empty());
+ }
}
TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
@@ -805,7 +834,12 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
TestObserver observer;
manager->AddObserver(&observer);
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ }
// Update with the same Intel GPU active.
EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1));
@@ -814,7 +848,12 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
run_loop.RunUntilIdle();
}
EXPECT_FALSE(observer.gpu_info_updated());
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ }
// Set NVIDIA GPU to be active.
EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640));
@@ -823,7 +862,12 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
run_loop.RunUntilIdle();
}
EXPECT_TRUE(observer.gpu_info_updated());
- EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
+ }
observer.Reset();
EXPECT_FALSE(observer.gpu_info_updated());
@@ -835,7 +879,12 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
run_loop.RunUntilIdle();
}
EXPECT_FALSE(observer.gpu_info_updated());
- EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
+ }
// Set Intel GPU to be active.
EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1));
@@ -844,7 +893,12 @@ TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
run_loop.RunUntilIdle();
}
EXPECT_TRUE(observer.gpu_info_updated());
- EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ if (manager->ShouldUseSwiftShader()) {
+ EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
+ manager->GetBlacklistedFeatureCount());
+ } else {
+ EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
+ }
}
} // namespace content
« no previous file with comments | « content/browser/gpu/gpu_data_manager_impl_private.cc ('k') | content/public/browser/gpu_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698