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

Side by Side 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 unified diff | Download patch
OLDNEW
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 ); 173 );
174 174
175 gpu::GPUInfo gpu_info; 175 gpu::GPUInfo gpu_info;
176 gpu_info.gpu.vendor_id = 0x10de; 176 gpu_info.gpu.vendor_id = 0x10de;
177 gpu_info.gpu.device_id = 0x0640; 177 gpu_info.gpu.device_id = 0x0640;
178 manager->InitializeForTesting(blacklist_json, gpu_info); 178 manager->InitializeForTesting(blacklist_json, gpu_info);
179 179
180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
181 EXPECT_TRUE(reason.empty()); 181 EXPECT_TRUE(reason.empty());
182 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 182 if (manager->ShouldUseSwiftShader()) {
183 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
184 manager->GetBlacklistedFeatureCount());
185 } else {
186 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
187 }
183 EXPECT_TRUE( 188 EXPECT_TRUE(
184 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); 189 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
185 190
186 gpu_info.gl_vendor = "NVIDIA"; 191 gpu_info.gl_vendor = "NVIDIA";
187 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; 192 gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
188 manager->UpdateGpuInfo(gpu_info); 193 manager->UpdateGpuInfo(gpu_info);
189 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); 194 if (manager->ShouldUseSwiftShader()) {
190 EXPECT_FALSE(reason.empty()); 195 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
191 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); 196 EXPECT_TRUE(reason.empty());
197 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
198 manager->GetBlacklistedFeatureCount());
199 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
200 } else {
201 EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
202 EXPECT_FALSE(reason.empty());
203 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount());
204 EXPECT_FALSE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
205 }
192 EXPECT_TRUE( 206 EXPECT_TRUE(
193 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); 207 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
194 EXPECT_TRUE(manager->IsFeatureBlacklisted( 208 EXPECT_TRUE(manager->IsFeatureBlacklisted(
195 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 209 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
196 } 210 }
197 211
198 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { 212 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) {
199 // If a feature is allowed in preliminary step (browser side), but 213 // If a feature is allowed in preliminary step (browser side), but
200 // disabled when GPU process launches and collects full GPU info, 214 // disabled when GPU process launches and collects full GPU info,
201 // it's too late to let renderer know, so we basically block all GPU 215 // it's too late to let renderer know, so we basically block all GPU
(...skipping 27 matching lines...) Expand all
229 } 243 }
230 ); 244 );
231 245
232 gpu::GPUInfo gpu_info; 246 gpu::GPUInfo gpu_info;
233 gpu_info.gpu.vendor_id = 0x10de; 247 gpu_info.gpu.vendor_id = 0x10de;
234 gpu_info.gpu.device_id = 0x0640; 248 gpu_info.gpu.device_id = 0x0640;
235 manager->InitializeForTesting(blacklist_json, gpu_info); 249 manager->InitializeForTesting(blacklist_json, gpu_info);
236 250
237 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 251 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
238 EXPECT_TRUE(reason.empty()); 252 EXPECT_TRUE(reason.empty());
239 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 253 if (manager->ShouldUseSwiftShader()) {
254 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
255 manager->GetBlacklistedFeatureCount());
256 } else {
257 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
258 }
240 EXPECT_TRUE(manager->IsFeatureBlacklisted( 259 EXPECT_TRUE(manager->IsFeatureBlacklisted(
241 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 260 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
242 261
243 gpu_info.gl_vendor = "NVIDIA"; 262 gpu_info.gl_vendor = "NVIDIA";
244 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; 263 gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
245 manager->UpdateGpuInfo(gpu_info); 264 manager->UpdateGpuInfo(gpu_info);
246 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 265 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
247 EXPECT_TRUE(reason.empty()); 266 EXPECT_TRUE(reason.empty());
248 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); 267 if (manager->ShouldUseSwiftShader()) {
268 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
269 manager->GetBlacklistedFeatureCount());
270 } else {
271 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount());
272 }
249 EXPECT_TRUE(manager->IsFeatureBlacklisted( 273 EXPECT_TRUE(manager->IsFeatureBlacklisted(
250 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 274 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
251 EXPECT_TRUE( 275 EXPECT_TRUE(
252 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); 276 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL));
253 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); 277 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
254 } 278 }
255 279
256 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { 280 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) {
257 ScopedGpuDataManagerImplPrivate manager; 281 ScopedGpuDataManagerImplPrivate manager;
258 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 282 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
(...skipping 17 matching lines...) Expand all
276 } 300 }
277 ] 301 ]
278 } 302 }
279 ); 303 );
280 gpu::GPUInfo gpu_info; 304 gpu::GPUInfo gpu_info;
281 gpu_info.gpu.vendor_id = 0x10de; 305 gpu_info.gpu.vendor_id = 0x10de;
282 gpu_info.gpu.device_id = 0x0640; 306 gpu_info.gpu.device_id = 0x0640;
283 manager->InitializeForTesting(blacklist_json, gpu_info); 307 manager->InitializeForTesting(blacklist_json, gpu_info);
284 308
285 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 309 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
286 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 310 EXPECT_EQ(manager->ShouldUseSwiftShader()
311 ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES)
312 : 1u,
313 manager->GetBlacklistedFeatureCount());
287 314
288 // Now assume gpu process launches and full GPU info is collected. 315 // Now assume gpu process launches and full GPU info is collected.
289 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; 316 gpu_info.gl_renderer = "NVIDIA GeForce GT 120";
290 manager->UpdateGpuInfo(gpu_info); 317 manager->UpdateGpuInfo(gpu_info);
291 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 318 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
292 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 319 // Since SwiftShader was enabled by first gpu_info, UpdateGpuInfo
320 // should have failed and SwiftShader should still be active
321 EXPECT_EQ(manager->ShouldUseSwiftShader()
322 ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES)
323 : 0u,
324 manager->GetBlacklistedFeatureCount());
293 } 325 }
294 326
295 TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) { 327 TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) {
296 ScopedGpuDataManagerImplPrivate manager; 328 ScopedGpuDataManagerImplPrivate manager;
297 manager->InitializeForTesting("", gpu::GPUInfo()); 329 manager->InitializeForTesting("", gpu::GPUInfo());
298 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 330 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
299 std::string reason; 331 std::string reason;
300 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 332 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
301 EXPECT_TRUE(reason.empty()); 333 EXPECT_TRUE(reason.empty());
302 334
303 manager->DisableHardwareAcceleration(); 335 manager->DisableHardwareAcceleration();
304 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); 336 if (manager->ShouldUseSwiftShader()) {
305 EXPECT_FALSE(reason.empty()); 337 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
338 EXPECT_TRUE(reason.empty());
339 } else {
340 EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
341 EXPECT_FALSE(reason.empty());
342 }
306 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), 343 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
307 manager->GetBlacklistedFeatureCount()); 344 manager->GetBlacklistedFeatureCount());
308 } 345 }
309 346
310 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) { 347 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) {
311 // Blacklist, then register SwiftShader. 348 // Blacklist, then register SwiftShader.
312 ScopedGpuDataManagerImplPrivate manager; 349 ScopedGpuDataManagerImplPrivate manager;
313 manager->InitializeForTesting("", gpu::GPUInfo()); 350 manager->InitializeForTesting("", gpu::GPUInfo());
314 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 351 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
315 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 352 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
316 EXPECT_FALSE(manager->ShouldUseSwiftShader()); 353 EXPECT_FALSE(manager->ShouldUseSwiftShader());
317 354
318 manager->DisableHardwareAcceleration(); 355 manager->DisableHardwareAcceleration();
319 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); 356 EXPECT_EQ(manager->ShouldUseSwiftShader(), manager->GpuAccessAllowed(NULL));
320 EXPECT_FALSE(manager->ShouldUseSwiftShader());
321
322 // If SwiftShader is enabled, even if we blacklist GPU,
323 // GPU process is still allowed.
324 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath"));
325 manager->RegisterSwiftShaderPath(test_path);
326 EXPECT_TRUE(manager->ShouldUseSwiftShader());
327 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
328 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), 357 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
329 manager->GetBlacklistedFeatureCount()); 358 manager->GetBlacklistedFeatureCount());
330 EXPECT_TRUE(manager->IsFeatureBlacklisted( 359 EXPECT_TRUE(manager->IsFeatureBlacklisted(
331 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 360 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
361 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
332 } 362 }
333 363
334 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { 364 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) {
335 // Register SwiftShader, then blacklist. 365 // Register SwiftShader, then blacklist.
336 ScopedGpuDataManagerImplPrivate manager; 366 ScopedGpuDataManagerImplPrivate manager;
337 manager->InitializeForTesting("", gpu::GPUInfo()); 367 manager->InitializeForTesting("", gpu::GPUInfo());
338 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 368 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
339 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 369 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
340 EXPECT_FALSE(manager->ShouldUseSwiftShader()); 370 EXPECT_FALSE(manager->ShouldUseSwiftShader());
341 371
342 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath"));
343 manager->RegisterSwiftShaderPath(test_path);
344 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
345 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
346 EXPECT_FALSE(manager->ShouldUseSwiftShader());
347
348 manager->DisableHardwareAcceleration(); 372 manager->DisableHardwareAcceleration();
349 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 373 if (manager->ShouldUseSwiftShader()) {
350 EXPECT_TRUE(manager->ShouldUseSwiftShader()); 374 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
375 } else {
376 EXPECT_FALSE(manager->GpuAccessAllowed(NULL));
377 }
351 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), 378 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
352 manager->GetBlacklistedFeatureCount()); 379 manager->GetBlacklistedFeatureCount());
353 EXPECT_TRUE(manager->IsFeatureBlacklisted( 380 EXPECT_TRUE(manager->IsFeatureBlacklisted(
354 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); 381 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS));
382 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2));
355 } 383 }
356 384
357 TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) { 385 TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) {
358 ScopedGpuDataManagerImpl manager; 386 ScopedGpuDataManagerImpl manager;
359 387
360 TestObserver observer; 388 TestObserver observer;
361 manager->AddObserver(&observer); 389 manager->AddObserver(&observer);
362 390
363 { 391 {
364 base::RunLoop run_loop; 392 base::RunLoop run_loop;
365 run_loop.RunUntilIdle(); 393 run_loop.RunUntilIdle();
366 } 394 }
367 EXPECT_FALSE(observer.gpu_info_updated()); 395 EXPECT_FALSE(observer.gpu_info_updated());
368 396
369 gpu::GPUInfo gpu_info; 397 gpu::GPUInfo gpu_info;
370 manager->UpdateGpuInfo(gpu_info); 398 manager->UpdateGpuInfo(gpu_info);
371 { 399 {
372 base::RunLoop run_loop; 400 base::RunLoop run_loop;
373 run_loop.RunUntilIdle(); 401 run_loop.RunUntilIdle();
374 } 402 }
375 EXPECT_TRUE(observer.gpu_info_updated()); 403 EXPECT_TRUE(observer.gpu_info_updated());
376 } 404 }
377 405
378 TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) { 406 TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) {
379 ScopedGpuDataManagerImpl manager; 407 ScopedGpuDataManagerImpl manager;
380 manager->InitializeForTesting("", gpu::GPUInfo()); 408 manager->InitializeForTesting("", gpu::GPUInfo());
381 409
382 manager->DisableHardwareAcceleration(); 410 manager->DisableHardwareAcceleration();
383 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); 411 if (manager->ShouldUseSwiftShader()) {
384 manager->RegisterSwiftShaderPath(test_path); 412 EXPECT_TRUE(manager->GpuAccessAllowed(NULL));
385 EXPECT_TRUE(manager->ShouldUseSwiftShader()); 413 } else {
386 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); 414 EXPECT_FALSE(manager->GpuAccessAllowed(NULL));
415 }
387 416
388 { 417 {
389 base::RunLoop run_loop; 418 base::RunLoop run_loop;
390 run_loop.RunUntilIdle(); 419 run_loop.RunUntilIdle();
391 } 420 }
392 421
393 TestObserver observer; 422 TestObserver observer;
394 manager->AddObserver(&observer); 423 manager->AddObserver(&observer);
395 { 424 {
396 base::RunLoop run_loop; 425 base::RunLoop run_loop;
397 run_loop.RunUntilIdle(); 426 run_loop.RunUntilIdle();
398 } 427 }
399 EXPECT_FALSE(observer.gpu_info_updated()); 428 EXPECT_FALSE(observer.gpu_info_updated());
400 429
401 gpu::GPUInfo gpu_info; 430 gpu::GPUInfo gpu_info;
402 manager->UpdateGpuInfo(gpu_info); 431 manager->UpdateGpuInfo(gpu_info);
403 { 432 {
404 base::RunLoop run_loop; 433 base::RunLoop run_loop;
405 run_loop.RunUntilIdle(); 434 run_loop.RunUntilIdle();
406 } 435 }
407 EXPECT_FALSE(observer.gpu_info_updated()); 436 if (manager->ShouldUseSwiftShader()) {
437 // Once SwiftShader is enabled, the gpu info can no longer be updated
438 EXPECT_FALSE(observer.gpu_info_updated());
439 } else {
440 EXPECT_TRUE(observer.gpu_info_updated());
441 }
408 } 442 }
409 443
410 TEST_F(GpuDataManagerImplPrivateTest, GPUVideoMemoryUsageStatsUpdate) { 444 TEST_F(GpuDataManagerImplPrivateTest, GPUVideoMemoryUsageStatsUpdate) {
411 ScopedGpuDataManagerImpl manager; 445 ScopedGpuDataManagerImpl manager;
412 446
413 TestObserver observer; 447 TestObserver observer;
414 manager->AddObserver(&observer); 448 manager->AddObserver(&observer);
415 449
416 { 450 {
417 base::RunLoop run_loop; 451 base::RunLoop run_loop;
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 786 }
753 ); 787 );
754 788
755 gpu::GPUInfo gpu_info; 789 gpu::GPUInfo gpu_info;
756 gpu_info.gpu.vendor_id = 0x10de; 790 gpu_info.gpu.vendor_id = 0x10de;
757 gpu_info.gpu.device_id = 0x0640; 791 gpu_info.gpu.device_id = 0x0640;
758 manager->InitializeForTesting(blacklist_json, gpu_info); 792 manager->InitializeForTesting(blacklist_json, gpu_info);
759 793
760 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), 794 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
761 manager->GetBlacklistedFeatureCount()); 795 manager->GetBlacklistedFeatureCount());
762 // TODO(zmo): remove the Linux specific behavior once we fix 796 if (manager->ShouldUseSwiftShader()) {
763 // crbug.com/238466. 797 EXPECT_TRUE(manager->GpuAccessAllowed(&reason));
764 #if defined(OS_LINUX) 798 EXPECT_TRUE(reason.empty());
765 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); 799 }
766 EXPECT_TRUE(reason.empty());
767 #else
768 EXPECT_FALSE(manager->GpuAccessAllowed(&reason));
769 EXPECT_FALSE(reason.empty());
770 #endif
771 } 800 }
772 801
773 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { 802 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) {
774 ScopedGpuDataManagerImpl manager; 803 ScopedGpuDataManagerImpl manager;
775 804
776 const std::string blacklist_json = LONG_STRING_CONST( 805 const std::string blacklist_json = LONG_STRING_CONST(
777 { 806 {
778 "name": "gpu blacklist", 807 "name": "gpu blacklist",
779 "version": "0.1", 808 "version": "0.1",
780 "entries": [ 809 "entries": [
(...skipping 17 matching lines...) Expand all
798 gpu::GPUInfo::GPUDevice intel_gpu; 827 gpu::GPUInfo::GPUDevice intel_gpu;
799 intel_gpu.vendor_id = 0x8086; 828 intel_gpu.vendor_id = 0x8086;
800 intel_gpu.device_id = 0x04a1; 829 intel_gpu.device_id = 0x04a1;
801 intel_gpu.active = true; 830 intel_gpu.active = true;
802 gpu_info.secondary_gpus.push_back(intel_gpu); 831 gpu_info.secondary_gpus.push_back(intel_gpu);
803 832
804 manager->InitializeForTesting(blacklist_json, gpu_info); 833 manager->InitializeForTesting(blacklist_json, gpu_info);
805 TestObserver observer; 834 TestObserver observer;
806 manager->AddObserver(&observer); 835 manager->AddObserver(&observer);
807 836
808 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 837 if (manager->ShouldUseSwiftShader()) {
838 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
839 manager->GetBlacklistedFeatureCount());
840 } else {
841 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
842 }
809 843
810 // Update with the same Intel GPU active. 844 // Update with the same Intel GPU active.
811 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1)); 845 EXPECT_FALSE(manager->UpdateActiveGpu(0x8086, 0x04a1));
812 { 846 {
813 base::RunLoop run_loop; 847 base::RunLoop run_loop;
814 run_loop.RunUntilIdle(); 848 run_loop.RunUntilIdle();
815 } 849 }
816 EXPECT_FALSE(observer.gpu_info_updated()); 850 EXPECT_FALSE(observer.gpu_info_updated());
817 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 851 if (manager->ShouldUseSwiftShader()) {
852 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
853 manager->GetBlacklistedFeatureCount());
854 } else {
855 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
856 }
818 857
819 // Set NVIDIA GPU to be active. 858 // Set NVIDIA GPU to be active.
820 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640)); 859 EXPECT_TRUE(manager->UpdateActiveGpu(0x10de, 0x0640));
821 { 860 {
822 base::RunLoop run_loop; 861 base::RunLoop run_loop;
823 run_loop.RunUntilIdle(); 862 run_loop.RunUntilIdle();
824 } 863 }
825 EXPECT_TRUE(observer.gpu_info_updated()); 864 EXPECT_TRUE(observer.gpu_info_updated());
826 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 865 if (manager->ShouldUseSwiftShader()) {
866 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
867 manager->GetBlacklistedFeatureCount());
868 } else {
869 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
870 }
827 871
828 observer.Reset(); 872 observer.Reset();
829 EXPECT_FALSE(observer.gpu_info_updated()); 873 EXPECT_FALSE(observer.gpu_info_updated());
830 874
831 // Update with the same NVIDIA GPU active. 875 // Update with the same NVIDIA GPU active.
832 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640)); 876 EXPECT_FALSE(manager->UpdateActiveGpu(0x10de, 0x0640));
833 { 877 {
834 base::RunLoop run_loop; 878 base::RunLoop run_loop;
835 run_loop.RunUntilIdle(); 879 run_loop.RunUntilIdle();
836 } 880 }
837 EXPECT_FALSE(observer.gpu_info_updated()); 881 EXPECT_FALSE(observer.gpu_info_updated());
838 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); 882 if (manager->ShouldUseSwiftShader()) {
883 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
884 manager->GetBlacklistedFeatureCount());
885 } else {
886 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount());
887 }
839 888
840 // Set Intel GPU to be active. 889 // Set Intel GPU to be active.
841 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); 890 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1));
842 { 891 {
843 base::RunLoop run_loop; 892 base::RunLoop run_loop;
844 run_loop.RunUntilIdle(); 893 run_loop.RunUntilIdle();
845 } 894 }
846 EXPECT_TRUE(observer.gpu_info_updated()); 895 EXPECT_TRUE(observer.gpu_info_updated());
847 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); 896 if (manager->ShouldUseSwiftShader()) {
897 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES),
898 manager->GetBlacklistedFeatureCount());
899 } else {
900 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount());
901 }
848 } 902 }
849 903
850 } // namespace content 904 } // namespace content
OLDNEW
« 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