| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 186 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
| 187 manager->UpdateGpuInfo(gpu_info); | 187 manager->UpdateGpuInfo(gpu_info); |
| 188 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); | 188 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
| 189 EXPECT_FALSE(reason.empty()); | 189 EXPECT_FALSE(reason.empty()); |
| 190 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); | 190 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
| 191 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 191 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); |
| 192 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 192 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 193 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 193 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 194 } | 194 } |
| 195 | 195 |
| 196 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { |
| 197 // If a feature is allowed in preliminary step (browser side), but |
| 198 // 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 |
| 200 // access, to be on the safe side. |
| 201 ScopedGpuDataManagerImplPrivate manager; |
| 202 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 203 std::string reason; |
| 204 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 205 EXPECT_TRUE(reason.empty()); |
| 206 |
| 207 const std::string blacklist_json = LONG_STRING_CONST( |
| 208 { |
| 209 "name": "gpu blacklist", |
| 210 "version": "0.1", |
| 211 "entries": [ |
| 212 { |
| 213 "id": 1, |
| 214 "features": [ |
| 215 "accelerated_2d_canvas" |
| 216 ] |
| 217 }, |
| 218 { |
| 219 "id": 2, |
| 220 "gl_renderer": ".*GeForce.*", |
| 221 "features": [ |
| 222 "webgl", |
| 223 "webgl2" |
| 224 ] |
| 225 } |
| 226 ] |
| 227 } |
| 228 ); |
| 229 |
| 230 gpu::GPUInfo gpu_info; |
| 231 gpu_info.gpu.vendor_id = 0x10de; |
| 232 gpu_info.gpu.device_id = 0x0640; |
| 233 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 234 |
| 235 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 236 EXPECT_TRUE(reason.empty()); |
| 237 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 238 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 239 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 240 |
| 241 gpu_info.gl_vendor = "NVIDIA"; |
| 242 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
| 243 manager->UpdateGpuInfo(gpu_info); |
| 244 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 245 EXPECT_TRUE(reason.empty()); |
| 246 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); |
| 247 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 248 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 249 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); |
| 250 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
| 251 } |
| 252 |
| 196 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { | 253 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { |
| 197 ScopedGpuDataManagerImplPrivate manager; | 254 ScopedGpuDataManagerImplPrivate manager; |
| 198 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 255 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 199 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 256 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 200 | 257 |
| 201 const std::string blacklist_json = LONG_STRING_CONST( | 258 const std::string blacklist_json = LONG_STRING_CONST( |
| 202 { | 259 { |
| 203 "name": "gpu blacklist", | 260 "name": "gpu blacklist", |
| 204 "version": "0.1", | 261 "version": "0.1", |
| 205 "entries": [ | 262 "entries": [ |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 832 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
| 776 { | 833 { |
| 777 base::RunLoop run_loop; | 834 base::RunLoop run_loop; |
| 778 run_loop.RunUntilIdle(); | 835 run_loop.RunUntilIdle(); |
| 779 } | 836 } |
| 780 EXPECT_TRUE(observer.gpu_info_updated()); | 837 EXPECT_TRUE(observer.gpu_info_updated()); |
| 781 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 838 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 782 } | 839 } |
| 783 | 840 |
| 784 } // namespace content | 841 } // namespace content |
| OLD | NEW |