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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // If a feature is allowed in preliminary step (browser side), but | 143 // If a feature is allowed in preliminary step (browser side), but |
144 // disabled when GPU process launches and collects full GPU info, | 144 // disabled when GPU process launches and collects full GPU info, |
145 // it's too late to let renderer know, so we basically block all GPU | 145 // it's too late to let renderer know, so we basically block all GPU |
146 // access, to be on the safe side. | 146 // access, to be on the safe side. |
147 ScopedGpuDataManagerImplPrivate manager; | 147 ScopedGpuDataManagerImplPrivate manager; |
148 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 148 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
149 std::string reason; | 149 std::string reason; |
150 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 150 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
151 EXPECT_TRUE(reason.empty()); | 151 EXPECT_TRUE(reason.empty()); |
152 | 152 |
153 const std::string blacklist_json = LONG_STRING_CONST( | 153 const std::string blacklist_json = LONG_STRING_CONST({ |
154 { | 154 "name" : "gpu blacklist", |
155 "name": "gpu blacklist", | 155 "version" : "0.1", |
156 "version": "0.1", | 156 "entries" : [ |
157 "entries": [ | 157 {"id" : 1, "features" : ["accelerated_webgl"]}, { |
158 { | 158 "id" : 2, |
159 "id": 1, | 159 "gl_renderer" : ".*GeForce.*", |
160 "features": [ | 160 "features" : ["accelerated_2d_canvas"] |
161 "webgl" | |
162 ] | |
163 }, | |
164 { | |
165 "id": 2, | |
166 "gl_renderer": ".*GeForce.*", | |
167 "features": [ | |
168 "accelerated_2d_canvas" | |
169 ] | |
170 } | |
171 ] | |
172 } | 161 } |
173 ); | 162 ] |
| 163 }); |
174 | 164 |
175 gpu::GPUInfo gpu_info; | 165 gpu::GPUInfo gpu_info; |
176 gpu_info.gpu.vendor_id = 0x10de; | 166 gpu_info.gpu.vendor_id = 0x10de; |
177 gpu_info.gpu.device_id = 0x0640; | 167 gpu_info.gpu.device_id = 0x0640; |
178 manager->InitializeForTesting(blacklist_json, gpu_info); | 168 manager->InitializeForTesting(blacklist_json, gpu_info); |
179 | 169 |
180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 170 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
181 EXPECT_TRUE(reason.empty()); | 171 EXPECT_TRUE(reason.empty()); |
182 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 172 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
183 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 173 EXPECT_TRUE( |
| 174 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
184 | 175 |
185 gpu_info.gl_vendor = "NVIDIA"; | 176 gpu_info.gl_vendor = "NVIDIA"; |
186 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 177 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
187 manager->UpdateGpuInfo(gpu_info); | 178 manager->UpdateGpuInfo(gpu_info); |
188 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); | 179 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
189 EXPECT_FALSE(reason.empty()); | 180 EXPECT_FALSE(reason.empty()); |
190 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); | 181 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
191 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 182 EXPECT_TRUE( |
| 183 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
192 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 184 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
193 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 185 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
194 } | 186 } |
195 | 187 |
196 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { | 188 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { |
197 // If a feature is allowed in preliminary step (browser side), but | 189 // If a feature is allowed in preliminary step (browser side), but |
198 // disabled when GPU process launches and collects full GPU info, | 190 // 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 | 191 // it's too late to let renderer know, so we basically block all GPU |
200 // access, to be on the safe side. | 192 // access, to be on the safe side. |
201 ScopedGpuDataManagerImplPrivate manager; | 193 ScopedGpuDataManagerImplPrivate manager; |
202 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 194 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
203 std::string reason; | 195 std::string reason; |
204 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 196 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
205 EXPECT_TRUE(reason.empty()); | 197 EXPECT_TRUE(reason.empty()); |
206 | 198 |
207 const std::string blacklist_json = LONG_STRING_CONST( | 199 const std::string blacklist_json = LONG_STRING_CONST({ |
208 { | 200 "name" : "gpu blacklist", |
209 "name": "gpu blacklist", | 201 "version" : "0.1", |
210 "version": "0.1", | 202 "entries" : [ |
211 "entries": [ | 203 {"id" : 1, "features" : ["accelerated_2d_canvas"]}, { |
212 { | 204 "id" : 2, |
213 "id": 1, | 205 "gl_renderer" : ".*GeForce.*", |
214 "features": [ | 206 "features" : [ "accelerated_webgl", "webgl2" ] |
215 "accelerated_2d_canvas" | |
216 ] | |
217 }, | |
218 { | |
219 "id": 2, | |
220 "gl_renderer": ".*GeForce.*", | |
221 "features": [ | |
222 "webgl", | |
223 "webgl2" | |
224 ] | |
225 } | |
226 ] | |
227 } | 207 } |
228 ); | 208 ] |
| 209 }); |
229 | 210 |
230 gpu::GPUInfo gpu_info; | 211 gpu::GPUInfo gpu_info; |
231 gpu_info.gpu.vendor_id = 0x10de; | 212 gpu_info.gpu.vendor_id = 0x10de; |
232 gpu_info.gpu.device_id = 0x0640; | 213 gpu_info.gpu.device_id = 0x0640; |
233 manager->InitializeForTesting(blacklist_json, gpu_info); | 214 manager->InitializeForTesting(blacklist_json, gpu_info); |
234 | 215 |
235 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 216 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
236 EXPECT_TRUE(reason.empty()); | 217 EXPECT_TRUE(reason.empty()); |
237 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 218 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
238 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 219 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
239 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 220 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
240 | 221 |
241 gpu_info.gl_vendor = "NVIDIA"; | 222 gpu_info.gl_vendor = "NVIDIA"; |
242 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 223 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
243 manager->UpdateGpuInfo(gpu_info); | 224 manager->UpdateGpuInfo(gpu_info); |
244 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 225 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
245 EXPECT_TRUE(reason.empty()); | 226 EXPECT_TRUE(reason.empty()); |
246 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); | 227 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); |
247 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 228 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
248 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 229 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
249 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 230 EXPECT_TRUE( |
| 231 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
250 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); | 232 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
251 } | 233 } |
252 | 234 |
253 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { | 235 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { |
254 ScopedGpuDataManagerImplPrivate manager; | 236 ScopedGpuDataManagerImplPrivate manager; |
255 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 237 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
256 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 238 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
257 | 239 |
258 const std::string blacklist_json = LONG_STRING_CONST( | 240 const std::string blacklist_json = LONG_STRING_CONST({ |
259 { | 241 "name" : "gpu blacklist", |
260 "name": "gpu blacklist", | 242 "version" : "0.1", |
261 "version": "0.1", | 243 "entries" : [ { |
262 "entries": [ | 244 "id" : 1, |
263 { | 245 "exceptions" : [ {"gl_renderer" : ".*GeForce.*"} ], |
264 "id": 1, | 246 "features" : ["accelerated_webgl"] |
265 "exceptions": [ | 247 } ] |
266 { | 248 }); |
267 "gl_renderer": ".*GeForce.*" | |
268 } | |
269 ], | |
270 "features": [ | |
271 "webgl" | |
272 ] | |
273 } | |
274 ] | |
275 } | |
276 ); | |
277 gpu::GPUInfo gpu_info; | 249 gpu::GPUInfo gpu_info; |
278 gpu_info.gpu.vendor_id = 0x10de; | 250 gpu_info.gpu.vendor_id = 0x10de; |
279 gpu_info.gpu.device_id = 0x0640; | 251 gpu_info.gpu.device_id = 0x0640; |
280 manager->InitializeForTesting(blacklist_json, gpu_info); | 252 manager->InitializeForTesting(blacklist_json, gpu_info); |
281 | 253 |
282 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 254 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
283 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 255 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
284 | 256 |
285 // Now assume gpu process launches and full GPU info is collected. | 257 // Now assume gpu process launches and full GPU info is collected. |
286 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 258 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 #if defined(OS_LINUX) | 520 #if defined(OS_LINUX) |
549 TEST_F(GpuDataManagerImplPrivateTest, SetGLStrings) { | 521 TEST_F(GpuDataManagerImplPrivateTest, SetGLStrings) { |
550 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 522 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
551 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 523 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
552 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 524 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
553 | 525 |
554 ScopedGpuDataManagerImplPrivate manager; | 526 ScopedGpuDataManagerImplPrivate manager; |
555 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 527 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
556 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 528 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
557 | 529 |
558 const std::string blacklist_json = LONG_STRING_CONST( | 530 const std::string blacklist_json = LONG_STRING_CONST({ |
559 { | 531 "name" : "gpu blacklist", |
560 "name": "gpu blacklist", | 532 "version" : "0.1", |
561 "version": "0.1", | 533 "entries" : [ { |
562 "entries": [ | 534 "id" : 1, |
563 { | 535 "vendor_id" : "0x8086", |
564 "id": 1, | 536 "exceptions" : [ { |
565 "vendor_id": "0x8086", | 537 "device_id" : ["0x0042"], |
566 "exceptions": [ | 538 "driver_version" : {"op" : ">=", "value" : "8.0.2"} |
567 { | 539 } ], |
568 "device_id": ["0x0042"], | 540 "features" : ["accelerated_webgl"] |
569 "driver_version": { | 541 } ] |
570 "op": ">=", | 542 }); |
571 "value": "8.0.2" | |
572 } | |
573 } | |
574 ], | |
575 "features": [ | |
576 "webgl" | |
577 ] | |
578 } | |
579 ] | |
580 } | |
581 ); | |
582 gpu::GPUInfo gpu_info; | 543 gpu::GPUInfo gpu_info; |
583 gpu_info.gpu.vendor_id = 0x8086; | 544 gpu_info.gpu.vendor_id = 0x8086; |
584 gpu_info.gpu.device_id = 0x0042; | 545 gpu_info.gpu.device_id = 0x0042; |
585 manager->InitializeForTesting(blacklist_json, gpu_info); | 546 manager->InitializeForTesting(blacklist_json, gpu_info); |
586 | 547 |
587 // Not enough GPUInfo. | 548 // Not enough GPUInfo. |
588 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 549 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
589 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 550 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
590 | 551 |
591 // Now assume browser gets GL strings from local state. | 552 // Now assume browser gets GL strings from local state. |
592 // The entry applies, blacklist more features than from the preliminary step. | 553 // The entry applies, blacklist more features than from the preliminary step. |
593 // However, GPU process is not blocked because this is all browser side and | 554 // However, GPU process is not blocked because this is all browser side and |
594 // happens before renderer launching. | 555 // happens before renderer launching. |
595 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 556 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
596 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 557 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
597 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 558 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
598 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 559 EXPECT_TRUE( |
| 560 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
599 } | 561 } |
600 | 562 |
601 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { | 563 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { |
602 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 564 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
603 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 565 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
604 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 566 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
605 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; | 567 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; |
606 | 568 |
607 ScopedGpuDataManagerImplPrivate manager; | 569 ScopedGpuDataManagerImplPrivate manager; |
608 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 570 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
609 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 571 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
610 | 572 |
611 const std::string blacklist_json = LONG_STRING_CONST( | 573 const std::string blacklist_json = LONG_STRING_CONST({ |
612 { | 574 "name" : "gpu blacklist", |
613 "name": "gpu blacklist", | 575 "version" : "0.1", |
614 "version": "0.1", | 576 "entries" : [ { |
615 "entries": [ | 577 "id" : 1, |
616 { | 578 "vendor_id" : "0x8086", |
617 "id": 1, | 579 "exceptions" : [ { |
618 "vendor_id": "0x8086", | 580 "device_id" : ["0x0042"], |
619 "exceptions": [ | 581 "driver_version" : {"op" : ">=", "value" : "8.0.2"} |
620 { | 582 } ], |
621 "device_id": ["0x0042"], | 583 "features" : ["accelerated_webgl"] |
622 "driver_version": { | 584 } ] |
623 "op": ">=", | 585 }); |
624 "value": "8.0.2" | |
625 } | |
626 } | |
627 ], | |
628 "features": [ | |
629 "webgl" | |
630 ] | |
631 } | |
632 ] | |
633 } | |
634 ); | |
635 gpu::GPUInfo gpu_info; | 586 gpu::GPUInfo gpu_info; |
636 gpu_info.gpu.vendor_id = 0x8086; | 587 gpu_info.gpu.vendor_id = 0x8086; |
637 gpu_info.gpu.device_id = 0x0042; | 588 gpu_info.gpu.device_id = 0x0042; |
638 gpu_info.gl_vendor = kGLVendorMesa; | 589 gpu_info.gl_vendor = kGLVendorMesa; |
639 gpu_info.gl_renderer = kGLRendererMesa; | 590 gpu_info.gl_renderer = kGLRendererMesa; |
640 gpu_info.gl_version = kGLVersionMesa801; | 591 gpu_info.gl_version = kGLVersionMesa801; |
641 gpu_info.driver_vendor = "Mesa"; | 592 gpu_info.driver_vendor = "Mesa"; |
642 gpu_info.driver_version = "8.0.1"; | 593 gpu_info.driver_version = "8.0.1"; |
643 manager->InitializeForTesting(blacklist_json, gpu_info); | 594 manager->InitializeForTesting(blacklist_json, gpu_info); |
644 | 595 |
645 // Full GPUInfo, the entry applies. | 596 // Full GPUInfo, the entry applies. |
646 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 597 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
647 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 598 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
648 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 599 EXPECT_TRUE( |
| 600 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
649 | 601 |
650 // Now assume browser gets GL strings from local state. | 602 // Now assume browser gets GL strings from local state. |
651 // SetGLStrings() has no effects because GPUInfo already got these strings. | 603 // SetGLStrings() has no effects because GPUInfo already got these strings. |
652 // (Otherwise the entry should not apply.) | 604 // (Otherwise the entry should not apply.) |
653 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); | 605 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); |
654 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 606 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
655 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 607 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
656 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 608 EXPECT_TRUE( |
| 609 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
657 } | 610 } |
658 | 611 |
659 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { | 612 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { |
660 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 613 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
661 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 614 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
662 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 615 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
663 | 616 |
664 ScopedGpuDataManagerImplPrivate manager; | 617 ScopedGpuDataManagerImplPrivate manager; |
665 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 618 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
666 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 619 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
667 | 620 |
668 const std::string blacklist_json = LONG_STRING_CONST({ | 621 const std::string blacklist_json = LONG_STRING_CONST({ |
669 "name" : "gpu blacklist", | 622 "name" : "gpu blacklist", |
670 "version" : "0.1", | 623 "version" : "0.1", |
671 "entries" : [ { | 624 "entries" : [ { |
672 "id" : 1, | 625 "id" : 1, |
673 "vendor_id" : "0x8086", | 626 "vendor_id" : "0x8086", |
674 "device_id" : ["0x0042"], | 627 "device_id" : ["0x0042"], |
675 "driver_vendor" : "Mesa", | 628 "driver_vendor" : "Mesa", |
676 "driver_version" : {"op" : ">=", "value" : "8.0.0"}, | 629 "driver_version" : {"op" : ">=", "value" : "8.0.0"}, |
677 "features" : ["webgl"] | 630 "features" : ["accelerated_webgl"] |
678 } ] | 631 } ] |
679 }); | 632 }); |
680 | 633 |
681 // Check that it is allowed to call SetGLStrings before Initialize. | 634 // Check that it is allowed to call SetGLStrings before Initialize. |
682 | 635 |
683 // Assume browser gets GL strings from local state. | 636 // Assume browser gets GL strings from local state. |
684 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 637 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
685 | 638 |
686 gpu::GPUInfo gpu_info; | 639 gpu::GPUInfo gpu_info; |
687 gpu_info.gpu.vendor_id = 0x8086; | 640 gpu_info.gpu.vendor_id = 0x8086; |
688 gpu_info.gpu.device_id = 0x0042; | 641 gpu_info.gpu.device_id = 0x0042; |
689 manager->InitializeForTesting(blacklist_json, gpu_info); | 642 manager->InitializeForTesting(blacklist_json, gpu_info); |
690 | 643 |
691 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 644 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
692 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 645 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
693 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 646 EXPECT_TRUE( |
| 647 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
694 } | 648 } |
695 #endif // OS_LINUX | 649 #endif // OS_LINUX |
696 | 650 |
697 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { | 651 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { |
698 ScopedGpuDataManagerImplPrivate manager; | 652 ScopedGpuDataManagerImplPrivate manager; |
699 manager->gpu_driver_bugs_.insert(5); | 653 manager->gpu_driver_bugs_.insert(5); |
700 | 654 |
701 base::CommandLine command_line(0, NULL); | 655 base::CommandLine command_line(0, NULL); |
702 manager->AppendGpuCommandLine(&command_line, nullptr); | 656 manager->AppendGpuCommandLine(&command_line, nullptr); |
703 | 657 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 EXPECT_TRUE(reason.empty()); | 711 EXPECT_TRUE(reason.empty()); |
758 #else | 712 #else |
759 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); | 713 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
760 EXPECT_FALSE(reason.empty()); | 714 EXPECT_FALSE(reason.empty()); |
761 #endif | 715 #endif |
762 } | 716 } |
763 | 717 |
764 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { | 718 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { |
765 ScopedGpuDataManagerImpl manager; | 719 ScopedGpuDataManagerImpl manager; |
766 | 720 |
767 const std::string blacklist_json = LONG_STRING_CONST( | 721 const std::string blacklist_json = LONG_STRING_CONST({ |
768 { | 722 "name" : "gpu blacklist", |
769 "name": "gpu blacklist", | 723 "version" : "0.1", |
770 "version": "0.1", | 724 "entries" : [ { |
771 "entries": [ | 725 "id" : 1, |
772 { | 726 "vendor_id" : "0x8086", |
773 "id": 1, | 727 "multi_gpu_category" : "active", |
774 "vendor_id": "0x8086", | 728 "features" : ["accelerated_webgl"] |
775 "multi_gpu_category": "active", | 729 } ] |
776 "features": [ | 730 }); |
777 "webgl" | |
778 ] | |
779 } | |
780 ] | |
781 } | |
782 ); | |
783 | 731 |
784 // Two GPUs, the secondary Intel GPU is active. | 732 // Two GPUs, the secondary Intel GPU is active. |
785 gpu::GPUInfo gpu_info; | 733 gpu::GPUInfo gpu_info; |
786 gpu_info.gpu.vendor_id = 0x10de; | 734 gpu_info.gpu.vendor_id = 0x10de; |
787 gpu_info.gpu.device_id = 0x0640; | 735 gpu_info.gpu.device_id = 0x0640; |
788 gpu_info.gpu.active = false; | 736 gpu_info.gpu.active = false; |
789 gpu::GPUInfo::GPUDevice intel_gpu; | 737 gpu::GPUInfo::GPUDevice intel_gpu; |
790 intel_gpu.vendor_id = 0x8086; | 738 intel_gpu.vendor_id = 0x8086; |
791 intel_gpu.device_id = 0x04a1; | 739 intel_gpu.device_id = 0x04a1; |
792 intel_gpu.active = true; | 740 intel_gpu.active = true; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 780 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
833 { | 781 { |
834 base::RunLoop run_loop; | 782 base::RunLoop run_loop; |
835 run_loop.RunUntilIdle(); | 783 run_loop.RunUntilIdle(); |
836 } | 784 } |
837 EXPECT_TRUE(observer.gpu_info_updated()); | 785 EXPECT_TRUE(observer.gpu_info_updated()); |
838 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 786 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
839 } | 787 } |
840 | 788 |
841 } // namespace content | 789 } // namespace content |
OLD | NEW |