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

Side by Side Diff: chrome/browser/gpu_blacklist_unittest.cc

Issue 5612002: Blacklist bad GPU drivers: currenly we disable all gpu related features if th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "chrome/browser/gpu_blacklist.h"
7
8 TEST(GpuBlacklistTest, BlacklistLogic) {
9 GPUInfo gpu_info;
10 gpu_info.SetGraphicsInfo(0x10de, // Vendor ID
11 0x0640, // Device ID
12 L"1.6.18", // Driver Version
13 0x0114, // Pixel Shader Version
14 0x0114, // Vertex Shader Version
15 0x0201, // GL version,
16 true); // can_lose_context
17 scoped_ptr<Version> os_version(Version::GetVersionFromString("10.6.4"));
18
19 GpuBlacklist blacklist;
20
21 // Default blacklist settings: all feature are allowed.
22 GpuFeatureFlags flags = blacklist.DetermineGpuFeatureFlags(
23 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
24 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
25 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
26 EXPECT_FALSE(flags.is_webgl_blacklisted());
27
28 // Empty list: all features are allowed.
29 const std::string empty_list_json =
30 "{\n"
31 " \"name\": \"gpu blacklist\",\n"
32 " \"version\": \"0.0\",\n"
33 " \"entries\": [\n"
34 " ]\n"
35 "}";
36 EXPECT_TRUE(blacklist.LoadGpuBlacklist(empty_list_json));
37 flags = blacklist.DetermineGpuFeatureFlags(
38 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
39 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
40 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
41 EXPECT_FALSE(flags.is_webgl_blacklisted());
42
43 // Blacklist accelerated_compositing with exact setting.
44 const std::string exact_list_json =
45 "{\n"
46 " \"name\": \"gpu blacklist\",\n"
47 " \"version\": \"0.1\",\n"
48 " \"entries\": [\n"
49 " {\n"
50 " \"os\": {\n"
51 " \"type\": \"macosx\",\n"
52 " \"version\": {\n"
53 " \"op\": \"=\",\n"
54 " \"number\": \"10.6.4\"\n"
55 " }\n"
56 " },\n"
57 " \"vendor_id\": \"0x10de\",\n"
58 " \"device_id\": \"0x0640\",\n"
59 " \"driver_version\": {\n"
60 " \"op\": \"=\",\n"
61 " \"number\": \"1.6.18\"\n"
62 " },\n"
63 " \"blacklist\": [\n"
64 " \"accelerated_compositing\",\n"
65 " ]\n"
66 " }\n"
67 " ]\n"
68 "}";
69 EXPECT_TRUE(blacklist.LoadGpuBlacklist(exact_list_json));
70 flags = blacklist.DetermineGpuFeatureFlags(
71 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
72 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
73 EXPECT_TRUE(flags.is_accelerated_compositing_blacklisted());
74 EXPECT_FALSE(flags.is_webgl_blacklisted());
75
76 // Invalid json input should not change the current blacklist settings.
77 const std::string invalid_json = "invalid";
78 EXPECT_FALSE(blacklist.LoadGpuBlacklist(invalid_json));
79 flags = blacklist.DetermineGpuFeatureFlags(
80 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
81 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
82 EXPECT_TRUE(flags.is_accelerated_compositing_blacklisted());
83 EXPECT_FALSE(flags.is_webgl_blacklisted());
84
85 // Blacklist a vendor on all OS.
86 const std::string vendor_json =
87 "{\n"
88 " \"name\": \"gpu blacklist\",\n"
89 " \"version\": \"0.1\",\n"
90 " \"entries\": [\n"
91 " {\n"
92 " \"vendor_id\": \"0x10de\",\n"
93 " \"blacklist\": [\n"
94 " \"webgl\",\n"
95 " ]\n"
96 " }\n"
97 " ]\n"
98 "}";
99 EXPECT_TRUE(blacklist.LoadGpuBlacklist(vendor_json));
100 flags = blacklist.DetermineGpuFeatureFlags(
101 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
102 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
103 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
104 EXPECT_TRUE(flags.is_webgl_blacklisted());
105 flags = blacklist.DetermineGpuFeatureFlags(
106 GpuBlacklist::kOsWin, os_version.get(), gpu_info);
107 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
108 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
109 EXPECT_TRUE(flags.is_webgl_blacklisted());
110 flags = blacklist.DetermineGpuFeatureFlags(
111 GpuBlacklist::kOsLinux, os_version.get(), gpu_info);
112 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
113 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
114 EXPECT_TRUE(flags.is_webgl_blacklisted());
115
116 // Blacklist a vendor on Linux only.
117 const std::string vendor_linux_json =
118 "{\n"
119 " \"name\": \"gpu blacklist\",\n"
120 " \"version\": \"0.1\",\n"
121 " \"entries\": [\n"
122 " {\n"
123 " \"os\": {\n"
124 " \"type\": \"linux\"\n"
125 " },\n"
126 " \"vendor_id\": \"0x10de\",\n"
127 " \"blacklist\": [\n"
128 " \"accelerated_2d_canvas\",\n"
129 " ]\n"
130 " }\n"
131 " ]\n"
132 "}";
133 EXPECT_TRUE(blacklist.LoadGpuBlacklist(vendor_linux_json));
134 flags = blacklist.DetermineGpuFeatureFlags(
135 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
136 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
137 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
138 EXPECT_FALSE(flags.is_webgl_blacklisted());
139 flags = blacklist.DetermineGpuFeatureFlags(
140 GpuBlacklist::kOsWin, os_version.get(), gpu_info);
141 EXPECT_FALSE(flags.is_accelerated_2d_canvas_blacklisted());
142 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
143 EXPECT_FALSE(flags.is_webgl_blacklisted());
144 flags = blacklist.DetermineGpuFeatureFlags(
145 GpuBlacklist::kOsLinux, os_version.get(), gpu_info);
146 EXPECT_TRUE(flags.is_accelerated_2d_canvas_blacklisted());
147 EXPECT_FALSE(flags.is_accelerated_compositing_blacklisted());
148 EXPECT_FALSE(flags.is_webgl_blacklisted());
149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698