| OLD | NEW |
| 1 // Copyright (c) 2012 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 <vector> | |
| 6 | |
| 7 #include "base/base_paths.h" | 5 #include "base/base_paths.h" |
| 8 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 10 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 12 #include "content/browser/gpu/gpu_blacklist.h" | 10 #include "content/browser/gpu/gpu_blacklist.h" |
| 11 #include "content/public/common/gpu_feature_type.h" |
| 13 #include "content/public/common/gpu_info.h" | 12 #include "content/public/common/gpu_info.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 14 |
| 16 const char kOsVersion[] = "10.6.4"; | 15 const char kOsVersion[] = "10.6.4"; |
| 17 const uint32 kIntelVendorId = 0x8086; | |
| 18 const uint32 kIntelDeviceId = 0x0166; // 3rd Gen Core Graphics | |
| 19 const uint32 kNvidiaVendorId = 0x10de; | |
| 20 const uint32 kNvidiaDeviceId = 0x0fd5; // GeForce GT 650M | |
| 21 | 16 |
| 22 namespace content { | 17 namespace content { |
| 23 | 18 |
| 24 class GpuBlacklistTest : public testing::Test { | 19 class GpuBlacklistTest : public testing::Test { |
| 25 public: | 20 public: |
| 26 GpuBlacklistTest() { } | 21 GpuBlacklistTest() { } |
| 27 | 22 |
| 28 virtual ~GpuBlacklistTest() { } | 23 virtual ~GpuBlacklistTest() { } |
| 29 | 24 |
| 30 const GPUInfo& gpu_info() const { | 25 const GPUInfo& gpu_info() const { |
| 31 return gpu_info_; | 26 return gpu_info_; |
| 32 } | 27 } |
| 33 | 28 |
| 34 GpuBlacklist* Create() { | 29 void RunFeatureTest( |
| 35 GpuBlacklist* rt = new GpuBlacklist(); | 30 const std::string feature_name, GpuFeatureType feature_type) { |
| 36 return rt; | 31 const std::string json = |
| 32 "{\n" |
| 33 " \"name\": \"gpu blacklist\",\n" |
| 34 " \"version\": \"0.1\",\n" |
| 35 " \"entries\": [\n" |
| 36 " {\n" |
| 37 " \"id\": 1,\n" |
| 38 " \"os\": {\n" |
| 39 " \"type\": \"macosx\"\n" |
| 40 " },\n" |
| 41 " \"vendor_id\": \"0x10de\",\n" |
| 42 " \"device_id\": [\"0x0640\"],\n" |
| 43 " \"features\": [\n" |
| 44 " \"" + |
| 45 feature_name + |
| 46 "\"\n" |
| 47 " ]\n" |
| 48 " }\n" |
| 49 " ]\n" |
| 50 "}"; |
| 51 |
| 52 scoped_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create()); |
| 53 EXPECT_TRUE(blacklist->LoadList(json, GpuBlacklist::kAllOs)); |
| 54 int type = blacklist->MakeDecision( |
| 55 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()); |
| 56 EXPECT_EQ(static_cast<int>(feature_type), type); |
| 37 } | 57 } |
| 38 | 58 |
| 39 protected: | 59 protected: |
| 40 virtual void SetUp() { | 60 virtual void SetUp() { |
| 41 gpu_info_.gpu.vendor_id = kNvidiaVendorId; | 61 gpu_info_.gpu.vendor_id = 0x10de; |
| 42 gpu_info_.gpu.device_id = 0x0640; | 62 gpu_info_.gpu.device_id = 0x0640; |
| 43 gpu_info_.driver_vendor = "NVIDIA"; | 63 gpu_info_.driver_vendor = "NVIDIA"; |
| 44 gpu_info_.driver_version = "1.6.18"; | 64 gpu_info_.driver_version = "1.6.18"; |
| 45 gpu_info_.driver_date = "7-14-2009"; | 65 gpu_info_.driver_date = "7-14-2009"; |
| 46 gpu_info_.machine_model = "MacBookPro 7.1"; | 66 gpu_info_.machine_model = "MacBookPro 7.1"; |
| 47 gpu_info_.gl_vendor = "NVIDIA Corporation"; | 67 gpu_info_.gl_vendor = "NVIDIA Corporation"; |
| 48 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; | 68 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; |
| 49 gpu_info_.performance_stats.graphics = 5.0; | 69 gpu_info_.performance_stats.graphics = 5.0; |
| 50 gpu_info_.performance_stats.gaming = 5.0; | 70 gpu_info_.performance_stats.gaming = 5.0; |
| 51 gpu_info_.performance_stats.overall = 5.0; | 71 gpu_info_.performance_stats.overall = 5.0; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 67 .Append(FILE_PATH_LITERAL("gpu")) | 87 .Append(FILE_PATH_LITERAL("gpu")) |
| 68 .Append(FILE_PATH_LITERAL("software_rendering_list.json")); | 88 .Append(FILE_PATH_LITERAL("software_rendering_list.json")); |
| 69 ASSERT_TRUE(file_util::PathExists(data_file)); | 89 ASSERT_TRUE(file_util::PathExists(data_file)); |
| 70 int64 data_file_size64 = 0; | 90 int64 data_file_size64 = 0; |
| 71 ASSERT_TRUE(file_util::GetFileSize(data_file, &data_file_size64)); | 91 ASSERT_TRUE(file_util::GetFileSize(data_file, &data_file_size64)); |
| 72 int data_file_size = static_cast<int>(data_file_size64); | 92 int data_file_size = static_cast<int>(data_file_size64); |
| 73 scoped_array<char> data(new char[data_file_size]); | 93 scoped_array<char> data(new char[data_file_size]); |
| 74 ASSERT_EQ(data_file_size, | 94 ASSERT_EQ(data_file_size, |
| 75 file_util::ReadFile(data_file, data.get(), data_file_size)); | 95 file_util::ReadFile(data_file, data.get(), data_file_size)); |
| 76 std::string json_string(data.get(), data_file_size); | 96 std::string json_string(data.get(), data_file_size); |
| 77 scoped_ptr<GpuBlacklist> blacklist(Create()); | 97 scoped_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create()); |
| 78 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json_string, GpuBlacklist::kAllOs)); | 98 EXPECT_TRUE(blacklist->LoadList(json_string, GpuBlacklist::kAllOs)); |
| 79 EXPECT_FALSE(blacklist->contains_unknown_fields()); | 99 EXPECT_FALSE(blacklist->contains_unknown_fields()); |
| 80 } | 100 } |
| 81 | 101 |
| 82 TEST_F(GpuBlacklistTest, DefaultBlacklistSettings) { | 102 #define GPU_BLACKLIST_FEATURE_TEST(test_name, feature_name, feature_type) \ |
| 83 scoped_ptr<GpuBlacklist> blacklist(Create()); | 103 TEST_F(GpuBlacklistTest, test_name) { \ |
| 84 // Default blacklist settings: all feature are allowed. | 104 RunFeatureTest(feature_name, feature_type); \ |
| 85 GpuBlacklist::Decision decision = blacklist->MakeBlacklistDecision( | |
| 86 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()); | |
| 87 EXPECT_EQ(0, decision.blacklisted_features); | |
| 88 EXPECT_EQ(GPU_SWITCHING_OPTION_UNKNOWN, decision.gpu_switching); | |
| 89 } | 105 } |
| 90 | 106 |
| 91 TEST_F(GpuBlacklistTest, EmptyBlacklist) { | 107 GPU_BLACKLIST_FEATURE_TEST(Accelerated2DCanvas, |
| 92 // Empty list: all features are allowed. | 108 "accelerated_2d_canvas", |
| 93 const std::string empty_list_json = | 109 GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) |
| 94 "{\n" | |
| 95 " \"name\": \"gpu blacklist\",\n" | |
| 96 " \"version\": \"2.5\",\n" | |
| 97 " \"entries\": [\n" | |
| 98 " ]\n" | |
| 99 "}"; | |
| 100 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 101 | 110 |
| 102 EXPECT_TRUE(blacklist->LoadGpuBlacklist(empty_list_json, | 111 GPU_BLACKLIST_FEATURE_TEST(AcceleratedCompositing, |
| 103 GpuBlacklist::kAllOs)); | 112 "accelerated_compositing", |
| 104 EXPECT_EQ("2.5", blacklist->GetVersion()); | 113 GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING) |
| 105 GpuBlacklist::Decision decision = blacklist->MakeBlacklistDecision( | |
| 106 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()); | |
| 107 EXPECT_EQ(0, decision.blacklisted_features); | |
| 108 EXPECT_EQ(GPU_SWITCHING_OPTION_UNKNOWN, decision.gpu_switching); | |
| 109 } | |
| 110 | 114 |
| 111 TEST_F(GpuBlacklistTest, DetailedEntryAndInvalidJson) { | 115 GPU_BLACKLIST_FEATURE_TEST(WebGL, |
| 112 // Blacklist accelerated_compositing with exact setting. | 116 "webgl", |
| 113 const std::string exact_list_json = | 117 GPU_FEATURE_TYPE_WEBGL) |
| 114 "{\n" | |
| 115 " \"name\": \"gpu blacklist\",\n" | |
| 116 " \"version\": \"0.1\",\n" | |
| 117 " \"entries\": [\n" | |
| 118 " {\n" | |
| 119 " \"id\": 5,\n" | |
| 120 " \"os\": {\n" | |
| 121 " \"type\": \"macosx\",\n" | |
| 122 " \"version\": {\n" | |
| 123 " \"op\": \"=\",\n" | |
| 124 " \"number\": \"10.6.4\"\n" | |
| 125 " }\n" | |
| 126 " },\n" | |
| 127 " \"vendor_id\": \"0x10de\",\n" | |
| 128 " \"device_id\": [\"0x0640\"],\n" | |
| 129 " \"driver_version\": {\n" | |
| 130 " \"op\": \"=\",\n" | |
| 131 " \"number\": \"1.6.18\"\n" | |
| 132 " },\n" | |
| 133 " \"blacklist\": [\n" | |
| 134 " \"accelerated_compositing\"\n" | |
| 135 " ]\n" | |
| 136 " }\n" | |
| 137 " ]\n" | |
| 138 "}"; | |
| 139 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 140 | 118 |
| 141 EXPECT_TRUE(blacklist->LoadGpuBlacklist(exact_list_json, | 119 GPU_BLACKLIST_FEATURE_TEST(Multisampling, |
| 142 GpuBlacklist::kAllOs)); | 120 "multisampling", |
| 143 GpuFeatureType type = blacklist->MakeBlacklistDecision( | 121 GPU_FEATURE_TYPE_MULTISAMPLING) |
| 144 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 145 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING, type); | |
| 146 | 122 |
| 147 // Invalid json input should not change the current blacklist settings. | 123 GPU_BLACKLIST_FEATURE_TEST(Flash3D, |
| 148 const std::string invalid_json = "invalid"; | 124 "flash_3d", |
| 125 GPU_FEATURE_TYPE_FLASH3D) |
| 149 | 126 |
| 150 EXPECT_FALSE(blacklist->LoadGpuBlacklist(invalid_json, GpuBlacklist::kAllOs)); | 127 GPU_BLACKLIST_FEATURE_TEST(FlashStage3D, |
| 151 type = blacklist->MakeBlacklistDecision( | 128 "flash_stage3d", |
| 152 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | 129 GPU_FEATURE_TYPE_FLASH_STAGE3D) |
| 153 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING, type); | |
| 154 std::vector<uint32> entries; | |
| 155 blacklist->GetDecisionEntries(&entries, false); | |
| 156 ASSERT_EQ(1u, entries.size()); | |
| 157 EXPECT_EQ(5u, entries[0]); | |
| 158 EXPECT_EQ(5u, blacklist->max_entry_id()); | |
| 159 } | |
| 160 | 130 |
| 161 TEST_F(GpuBlacklistTest, VendorOnAllOsEntry) { | 131 GPU_BLACKLIST_FEATURE_TEST(FlashStage3DBaseline, |
| 162 // Blacklist a vendor on all OS. | 132 "flash_stage3d_baseline", |
| 163 const std::string vendor_json = | 133 GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE) |
| 164 "{\n" | |
| 165 " \"name\": \"gpu blacklist\",\n" | |
| 166 " \"version\": \"0.1\",\n" | |
| 167 " \"entries\": [\n" | |
| 168 " {\n" | |
| 169 " \"id\": 1,\n" | |
| 170 " \"vendor_id\": \"0x10de\",\n" | |
| 171 " \"blacklist\": [\n" | |
| 172 " \"webgl\"\n" | |
| 173 " ]\n" | |
| 174 " }\n" | |
| 175 " ]\n" | |
| 176 "}"; | |
| 177 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 178 | 134 |
| 179 // Blacklist entries won't be filtered to the current OS only upon loading. | 135 GPU_BLACKLIST_FEATURE_TEST(TextureSharing, |
| 180 EXPECT_TRUE(blacklist->LoadGpuBlacklist(vendor_json, GpuBlacklist::kAllOs)); | 136 "texture_sharing", |
| 181 GpuFeatureType type = blacklist->MakeBlacklistDecision( | 137 GPU_FEATURE_TYPE_TEXTURE_SHARING) |
| 182 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 183 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 184 type = blacklist->MakeBlacklistDecision( | |
| 185 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 186 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 187 type = blacklist->MakeBlacklistDecision( | |
| 188 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).blacklisted_features; | |
| 189 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 190 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_MACOSX) || \ | |
| 191 defined(OS_OPENBSD) | |
| 192 // Blacklist entries will be filtered to the current OS only upon loading. | |
| 193 EXPECT_TRUE(blacklist->LoadGpuBlacklist(vendor_json, | |
| 194 GpuBlacklist::kCurrentOsOnly)); | |
| 195 type = blacklist->MakeBlacklistDecision( | |
| 196 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 197 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 198 type = blacklist->MakeBlacklistDecision( | |
| 199 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 200 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 201 type = blacklist->MakeBlacklistDecision( | |
| 202 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).blacklisted_features; | |
| 203 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 204 #endif | |
| 205 } | |
| 206 | 138 |
| 207 TEST_F(GpuBlacklistTest, VendorOnLinuxEntry) { | 139 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideoDecode, |
| 208 // Blacklist a vendor on Linux only. | 140 "accelerated_video_decode", |
| 209 const std::string vendor_linux_json = | 141 GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) |
| 210 "{\n" | |
| 211 " \"name\": \"gpu blacklist\",\n" | |
| 212 " \"version\": \"0.1\",\n" | |
| 213 " \"entries\": [\n" | |
| 214 " {\n" | |
| 215 " \"id\": 1,\n" | |
| 216 " \"os\": {\n" | |
| 217 " \"type\": \"linux\"\n" | |
| 218 " },\n" | |
| 219 " \"vendor_id\": \"0x10de\",\n" | |
| 220 " \"blacklist\": [\n" | |
| 221 " \"accelerated_2d_canvas\"\n" | |
| 222 " ]\n" | |
| 223 " }\n" | |
| 224 " ]\n" | |
| 225 "}"; | |
| 226 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 227 | 142 |
| 228 EXPECT_TRUE(blacklist->LoadGpuBlacklist(vendor_linux_json, | 143 GPU_BLACKLIST_FEATURE_TEST(Css3D, |
| 229 GpuBlacklist::kAllOs)); | 144 "3d_css", |
| 230 GpuFeatureType type = blacklist->MakeBlacklistDecision( | 145 GPU_FEATURE_TYPE_3D_CSS) |
| 231 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 232 EXPECT_EQ(0, type); | |
| 233 type = blacklist->MakeBlacklistDecision( | |
| 234 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 235 EXPECT_EQ(0, type); | |
| 236 type = blacklist->MakeBlacklistDecision( | |
| 237 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).blacklisted_features; | |
| 238 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, type); | |
| 239 } | |
| 240 | 146 |
| 241 TEST_F(GpuBlacklistTest, AllExceptNVidiaOnLinuxEntry) { | 147 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideo, |
| 242 // Blacklist all cards in Linux except NVIDIA. | 148 "accelerated_video", |
| 243 const std::string linux_except_nvidia_json = | 149 GPU_FEATURE_TYPE_ACCELERATED_VIDEO) |
| 244 "{\n" | |
| 245 " \"name\": \"gpu blacklist\",\n" | |
| 246 " \"version\": \"0.1\",\n" | |
| 247 " \"entries\": [\n" | |
| 248 " {\n" | |
| 249 " \"id\": 1,\n" | |
| 250 " \"os\": {\n" | |
| 251 " \"type\": \"linux\"\n" | |
| 252 " },\n" | |
| 253 " \"exceptions\": [\n" | |
| 254 " {\n" | |
| 255 " \"vendor_id\": \"0x10de\"\n" | |
| 256 " }\n" | |
| 257 " ],\n" | |
| 258 " \"blacklist\": [\n" | |
| 259 " \"accelerated_2d_canvas\"\n" | |
| 260 " ]\n" | |
| 261 " }\n" | |
| 262 " ]\n" | |
| 263 "}"; | |
| 264 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 265 | 150 |
| 266 EXPECT_TRUE(blacklist->LoadGpuBlacklist(linux_except_nvidia_json, | 151 GPU_BLACKLIST_FEATURE_TEST(PanelFitting, |
| 267 GpuBlacklist::kAllOs)); | 152 "panel_fitting", |
| 268 GpuFeatureType type = blacklist->MakeBlacklistDecision( | 153 GPU_FEATURE_TYPE_PANEL_FITTING) |
| 269 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 270 EXPECT_EQ(0, type); | |
| 271 type = blacklist->MakeBlacklistDecision( | |
| 272 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 273 EXPECT_EQ(0, type); | |
| 274 type = blacklist->MakeBlacklistDecision( | |
| 275 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).blacklisted_features; | |
| 276 EXPECT_EQ(0, type); | |
| 277 } | |
| 278 | 154 |
| 279 TEST_F(GpuBlacklistTest, AllExceptIntelOnLinuxEntry) { | 155 GPU_BLACKLIST_FEATURE_TEST(ForceCompositingMode, |
| 280 // Blacklist all cards in Linux except Intel. | 156 "force_compositing_mode", |
| 281 const std::string linux_except_intel_json = | 157 GPU_FEATURE_TYPE_FORCE_COMPOSITING_MODE) |
| 282 "{\n" | |
| 283 " \"name\": \"gpu blacklist\",\n" | |
| 284 " \"version\": \"0.1\",\n" | |
| 285 " \"entries\": [\n" | |
| 286 " {\n" | |
| 287 " \"id\": 1,\n" | |
| 288 " \"os\": {\n" | |
| 289 " \"type\": \"linux\"\n" | |
| 290 " },\n" | |
| 291 " \"exceptions\": [\n" | |
| 292 " {\n" | |
| 293 " \"vendor_id\": \"0x8086\"\n" | |
| 294 " }\n" | |
| 295 " ],\n" | |
| 296 " \"blacklist\": [\n" | |
| 297 " \"accelerated_2d_canvas\"\n" | |
| 298 " ]\n" | |
| 299 " }\n" | |
| 300 " ]\n" | |
| 301 "}"; | |
| 302 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 303 | 158 |
| 304 EXPECT_TRUE(blacklist->LoadGpuBlacklist(linux_except_intel_json, | 159 GPU_BLACKLIST_FEATURE_TEST(All, |
| 305 GpuBlacklist::kAllOs)); | 160 "all", |
| 306 GpuFeatureType type = blacklist->MakeBlacklistDecision( | 161 GPU_FEATURE_TYPE_ALL) |
| 307 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 308 EXPECT_EQ(0, type); | |
| 309 type = blacklist->MakeBlacklistDecision( | |
| 310 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 311 EXPECT_EQ(0, type); | |
| 312 type = blacklist->MakeBlacklistDecision( | |
| 313 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).blacklisted_features; | |
| 314 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, type); | |
| 315 } | |
| 316 | |
| 317 TEST_F(GpuBlacklistTest, DateOnWindowsEntry) { | |
| 318 // Blacklist all drivers earlier than 2010-5-8 in Windows. | |
| 319 const std::string date_windows_json = | |
| 320 "{\n" | |
| 321 " \"name\": \"gpu blacklist\",\n" | |
| 322 " \"version\": \"0.1\",\n" | |
| 323 " \"entries\": [\n" | |
| 324 " {\n" | |
| 325 " \"id\": 1,\n" | |
| 326 " \"os\": {\n" | |
| 327 " \"type\": \"win\"\n" | |
| 328 " },\n" | |
| 329 " \"driver_date\": {\n" | |
| 330 " \"op\": \"<\",\n" | |
| 331 " \"number\": \"2010.5.8\"\n" | |
| 332 " },\n" | |
| 333 " \"blacklist\": [\n" | |
| 334 " \"accelerated_2d_canvas\"\n" | |
| 335 " ]\n" | |
| 336 " }\n" | |
| 337 " ]\n" | |
| 338 "}"; | |
| 339 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 340 | |
| 341 GPUInfo gpu_info; | |
| 342 gpu_info.driver_date = "7-14-2009"; | |
| 343 | |
| 344 EXPECT_TRUE( | |
| 345 blacklist->LoadGpuBlacklist(date_windows_json, GpuBlacklist::kAllOs)); | |
| 346 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 347 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 348 EXPECT_EQ(0, type); | |
| 349 type = blacklist->MakeBlacklistDecision( | |
| 350 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 351 EXPECT_EQ(0, type); | |
| 352 type = blacklist->MakeBlacklistDecision( | |
| 353 GpuBlacklist::kOsWin, kOsVersion, gpu_info).blacklisted_features; | |
| 354 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, type); | |
| 355 | |
| 356 gpu_info.driver_date = "07-14-2009"; | |
| 357 type = blacklist->MakeBlacklistDecision( | |
| 358 GpuBlacklist::kOsWin, kOsVersion, gpu_info).blacklisted_features; | |
| 359 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, type); | |
| 360 | |
| 361 gpu_info.driver_date = "1-1-2010"; | |
| 362 type = blacklist->MakeBlacklistDecision( | |
| 363 GpuBlacklist::kOsWin, kOsVersion, gpu_info).blacklisted_features; | |
| 364 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, type); | |
| 365 | |
| 366 gpu_info.driver_date = "05-07-2010"; | |
| 367 type = blacklist->MakeBlacklistDecision( | |
| 368 GpuBlacklist::kOsWin, kOsVersion, gpu_info).blacklisted_features; | |
| 369 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS, type); | |
| 370 | |
| 371 gpu_info.driver_date = "5-8-2010"; | |
| 372 type = blacklist->MakeBlacklistDecision( | |
| 373 GpuBlacklist::kOsWin, kOsVersion, gpu_info).blacklisted_features; | |
| 374 EXPECT_EQ(0, type); | |
| 375 | |
| 376 gpu_info.driver_date = "5-9-2010"; | |
| 377 type = blacklist->MakeBlacklistDecision( | |
| 378 GpuBlacklist::kOsWin, kOsVersion, gpu_info).blacklisted_features; | |
| 379 EXPECT_EQ(0, type); | |
| 380 | |
| 381 gpu_info.driver_date = "6-2-2010"; | |
| 382 type = blacklist->MakeBlacklistDecision( | |
| 383 GpuBlacklist::kOsWin, kOsVersion, gpu_info).blacklisted_features; | |
| 384 EXPECT_EQ(0, type); | |
| 385 } | |
| 386 | |
| 387 TEST_F(GpuBlacklistTest, MultipleDevicesEntry) { | |
| 388 const std::string devices_json = | |
| 389 "{\n" | |
| 390 " \"name\": \"gpu blacklist\",\n" | |
| 391 " \"version\": \"0.1\",\n" | |
| 392 " \"entries\": [\n" | |
| 393 " {\n" | |
| 394 " \"id\": 1,\n" | |
| 395 " \"vendor_id\": \"0x10de\",\n" | |
| 396 " \"device_id\": [\"0x1023\", \"0x0640\"],\n" | |
| 397 " \"blacklist\": [\n" | |
| 398 " \"multisampling\"\n" | |
| 399 " ]\n" | |
| 400 " }\n" | |
| 401 " ]\n" | |
| 402 "}"; | |
| 403 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 404 | |
| 405 EXPECT_TRUE(blacklist->LoadGpuBlacklist(devices_json, GpuBlacklist::kAllOs)); | |
| 406 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 407 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 408 EXPECT_EQ(GPU_FEATURE_TYPE_MULTISAMPLING, type); | |
| 409 type = blacklist->MakeBlacklistDecision( | |
| 410 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 411 EXPECT_EQ(GPU_FEATURE_TYPE_MULTISAMPLING, type); | |
| 412 type = blacklist->MakeBlacklistDecision( | |
| 413 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).blacklisted_features; | |
| 414 EXPECT_EQ(GPU_FEATURE_TYPE_MULTISAMPLING, type); | |
| 415 } | |
| 416 | |
| 417 TEST_F(GpuBlacklistTest, ChromeOSEntry) { | |
| 418 const std::string devices_json = | |
| 419 "{\n" | |
| 420 " \"name\": \"gpu blacklist\",\n" | |
| 421 " \"version\": \"0.1\",\n" | |
| 422 " \"entries\": [\n" | |
| 423 " {\n" | |
| 424 " \"id\": 1,\n" | |
| 425 " \"os\": {\n" | |
| 426 " \"type\": \"chromeos\"\n" | |
| 427 " },\n" | |
| 428 " \"blacklist\": [\n" | |
| 429 " \"webgl\"\n" | |
| 430 " ]\n" | |
| 431 " }\n" | |
| 432 " ]\n" | |
| 433 "}"; | |
| 434 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 435 | |
| 436 EXPECT_TRUE(blacklist->LoadGpuBlacklist(devices_json, GpuBlacklist::kAllOs)); | |
| 437 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 438 GpuBlacklist::kOsChromeOS, kOsVersion, gpu_info()).blacklisted_features; | |
| 439 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 440 type = blacklist->MakeBlacklistDecision( | |
| 441 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).blacklisted_features; | |
| 442 EXPECT_EQ(0, type); | |
| 443 } | |
| 444 | |
| 445 TEST_F(GpuBlacklistTest, ChromeVersionEntry) { | |
| 446 const std::string browser_version_json = | |
| 447 "{\n" | |
| 448 " \"name\": \"gpu blacklist\",\n" | |
| 449 " \"version\": \"0.1\",\n" | |
| 450 " \"entries\": [\n" | |
| 451 " {\n" | |
| 452 " \"id\": 1,\n" | |
| 453 " \"browser_version\": {\n" | |
| 454 " \"op\": \">=\",\n" | |
| 455 " \"number\": \"10\"\n" | |
| 456 " },\n" | |
| 457 " \"blacklist\": [\n" | |
| 458 " \"webgl\"\n" | |
| 459 " ]\n" | |
| 460 " }\n" | |
| 461 " ]\n" | |
| 462 "}"; | |
| 463 | |
| 464 scoped_ptr<GpuBlacklist> blacklist9(Create()); | |
| 465 EXPECT_TRUE(blacklist9->LoadGpuBlacklist("9.0", browser_version_json, | |
| 466 GpuBlacklist::kAllOs)); | |
| 467 GpuFeatureType type = blacklist9->MakeBlacklistDecision( | |
| 468 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 469 EXPECT_EQ(0, type); | |
| 470 | |
| 471 scoped_ptr<GpuBlacklist> blacklist10(Create()); | |
| 472 EXPECT_TRUE(blacklist10->LoadGpuBlacklist("10.0", browser_version_json, | |
| 473 GpuBlacklist::kAllOs)); | |
| 474 type = blacklist10->MakeBlacklistDecision( | |
| 475 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 476 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 477 } | |
| 478 | |
| 479 TEST_F(GpuBlacklistTest, MalformedVendor) { | |
| 480 // vendor_id is defined as list instead of string. | |
| 481 const std::string malformed_vendor_json = | |
| 482 "{\n" | |
| 483 " \"name\": \"gpu blacklist\",\n" | |
| 484 " \"version\": \"0.1\",\n" | |
| 485 " \"entries\": [\n" | |
| 486 " {\n" | |
| 487 " \"id\": 1,\n" | |
| 488 " \"vendor_id\": \"[0x10de]\",\n" | |
| 489 " \"blacklist\": [\n" | |
| 490 " \"accelerated_2d_canvas\"\n" | |
| 491 " ]\n" | |
| 492 " }\n" | |
| 493 " ]\n" | |
| 494 "}"; | |
| 495 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 496 | |
| 497 EXPECT_FALSE(blacklist->LoadGpuBlacklist(malformed_vendor_json, | |
| 498 GpuBlacklist::kAllOs)); | |
| 499 } | |
| 500 | |
| 501 TEST_F(GpuBlacklistTest, UnknownField) { | |
| 502 const std::string unknown_field_json = | |
| 503 "{\n" | |
| 504 " \"name\": \"gpu blacklist\",\n" | |
| 505 " \"version\": \"0.1\",\n" | |
| 506 " \"entries\": [\n" | |
| 507 " {\n" | |
| 508 " \"id\": 1,\n" | |
| 509 " \"unknown_field\": 0,\n" | |
| 510 " \"blacklist\": [\n" | |
| 511 " \"accelerated_2d_canvas\"\n" | |
| 512 " ]\n" | |
| 513 " },\n" | |
| 514 " {\n" | |
| 515 " \"id\": 2,\n" | |
| 516 " \"blacklist\": [\n" | |
| 517 " \"webgl\"\n" | |
| 518 " ]\n" | |
| 519 " }\n" | |
| 520 " ]\n" | |
| 521 "}"; | |
| 522 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 523 | |
| 524 EXPECT_TRUE(blacklist->LoadGpuBlacklist(unknown_field_json, | |
| 525 GpuBlacklist::kAllOs)); | |
| 526 EXPECT_EQ(1u, blacklist->num_entries()); | |
| 527 EXPECT_TRUE(blacklist->contains_unknown_fields()); | |
| 528 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 529 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 530 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 531 } | |
| 532 | |
| 533 TEST_F(GpuBlacklistTest, UnknownExceptionField) { | |
| 534 const std::string unknown_exception_field_json = | |
| 535 "{\n" | |
| 536 " \"name\": \"gpu blacklist\",\n" | |
| 537 " \"version\": \"0.1\",\n" | |
| 538 " \"entries\": [\n" | |
| 539 " {\n" | |
| 540 " \"id\": 1,\n" | |
| 541 " \"unknown_field\": 0,\n" | |
| 542 " \"blacklist\": [\n" | |
| 543 " \"accelerated_compositing\"\n" | |
| 544 " ]\n" | |
| 545 " },\n" | |
| 546 " {\n" | |
| 547 " \"id\": 2,\n" | |
| 548 " \"exceptions\": [\n" | |
| 549 " {\n" | |
| 550 " \"unknown_field\": 0\n" | |
| 551 " }\n" | |
| 552 " ],\n" | |
| 553 " \"blacklist\": [\n" | |
| 554 " \"accelerated_2d_canvas\"\n" | |
| 555 " ]\n" | |
| 556 " },\n" | |
| 557 " {\n" | |
| 558 " \"id\": 3,\n" | |
| 559 " \"blacklist\": [\n" | |
| 560 " \"webgl\"\n" | |
| 561 " ]\n" | |
| 562 " }\n" | |
| 563 " ]\n" | |
| 564 "}"; | |
| 565 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 566 | |
| 567 EXPECT_TRUE(blacklist->LoadGpuBlacklist(unknown_exception_field_json, | |
| 568 GpuBlacklist::kAllOs)); | |
| 569 EXPECT_EQ(1u, blacklist->num_entries()); | |
| 570 EXPECT_TRUE(blacklist->contains_unknown_fields()); | |
| 571 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 572 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 573 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 574 } | |
| 575 | |
| 576 TEST_F(GpuBlacklistTest, UnknownFeature) { | |
| 577 const std::string unknown_feature_json = | |
| 578 "{\n" | |
| 579 " \"name\": \"gpu blacklist\",\n" | |
| 580 " \"version\": \"0.1\",\n" | |
| 581 " \"entries\": [\n" | |
| 582 " {\n" | |
| 583 " \"id\": 1,\n" | |
| 584 " \"blacklist\": [\n" | |
| 585 " \"accelerated_something\",\n" | |
| 586 " \"webgl\"\n" | |
| 587 " ]\n" | |
| 588 " }\n" | |
| 589 " ]\n" | |
| 590 "}"; | |
| 591 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 592 | |
| 593 EXPECT_TRUE(blacklist->LoadGpuBlacklist(unknown_feature_json, | |
| 594 GpuBlacklist::kAllOs)); | |
| 595 EXPECT_EQ(1u, blacklist->num_entries()); | |
| 596 EXPECT_TRUE(blacklist->contains_unknown_fields()); | |
| 597 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 598 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 599 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 600 } | |
| 601 | |
| 602 TEST_F(GpuBlacklistTest, GlVendor) { | |
| 603 const std::string gl_vendor_json = | |
| 604 "{\n" | |
| 605 " \"name\": \"gpu blacklist\",\n" | |
| 606 " \"version\": \"0.1\",\n" | |
| 607 " \"entries\": [\n" | |
| 608 " {\n" | |
| 609 " \"id\": 1,\n" | |
| 610 " \"gl_vendor\": {\n" | |
| 611 " \"op\": \"beginwith\",\n" | |
| 612 " \"value\": \"NVIDIA\"\n" | |
| 613 " },\n" | |
| 614 " \"blacklist\": [\n" | |
| 615 " \"webgl\"\n" | |
| 616 " ]\n" | |
| 617 " }\n" | |
| 618 " ]\n" | |
| 619 "}"; | |
| 620 | |
| 621 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 622 EXPECT_TRUE(blacklist->LoadGpuBlacklist(gl_vendor_json, | |
| 623 GpuBlacklist::kAllOs)); | |
| 624 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 625 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 626 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 627 } | |
| 628 | |
| 629 TEST_F(GpuBlacklistTest, GlRenderer) { | |
| 630 const std::string gl_renderer_json = | |
| 631 "{\n" | |
| 632 " \"name\": \"gpu blacklist\",\n" | |
| 633 " \"version\": \"0.1\",\n" | |
| 634 " \"entries\": [\n" | |
| 635 " {\n" | |
| 636 " \"id\": 1,\n" | |
| 637 " \"gl_renderer\": {\n" | |
| 638 " \"op\": \"contains\",\n" | |
| 639 " \"value\": \"GeForce\"\n" | |
| 640 " },\n" | |
| 641 " \"blacklist\": [\n" | |
| 642 " \"webgl\"\n" | |
| 643 " ]\n" | |
| 644 " }\n" | |
| 645 " ]\n" | |
| 646 "}"; | |
| 647 | |
| 648 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 649 EXPECT_TRUE(blacklist->LoadGpuBlacklist(gl_renderer_json, | |
| 650 GpuBlacklist::kAllOs)); | |
| 651 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 652 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 653 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 654 } | |
| 655 | |
| 656 TEST_F(GpuBlacklistTest, PerfGraphics) { | |
| 657 const std::string json = | |
| 658 "{\n" | |
| 659 " \"name\": \"gpu blacklist\",\n" | |
| 660 " \"version\": \"0.1\",\n" | |
| 661 " \"entries\": [\n" | |
| 662 " {\n" | |
| 663 " \"id\": 1,\n" | |
| 664 " \"perf_graphics\": {\n" | |
| 665 " \"op\": \"<\",\n" | |
| 666 " \"value\": \"6.0\"\n" | |
| 667 " },\n" | |
| 668 " \"blacklist\": [\n" | |
| 669 " \"webgl\"\n" | |
| 670 " ]\n" | |
| 671 " }\n" | |
| 672 " ]\n" | |
| 673 "}"; | |
| 674 | |
| 675 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 676 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); | |
| 677 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 678 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 679 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 680 } | |
| 681 | |
| 682 TEST_F(GpuBlacklistTest, PerfGaming) { | |
| 683 const std::string json = | |
| 684 "{\n" | |
| 685 " \"name\": \"gpu blacklist\",\n" | |
| 686 " \"version\": \"0.1\",\n" | |
| 687 " \"entries\": [\n" | |
| 688 " {\n" | |
| 689 " \"id\": 1,\n" | |
| 690 " \"perf_gaming\": {\n" | |
| 691 " \"op\": \"<=\",\n" | |
| 692 " \"value\": \"4.0\"\n" | |
| 693 " },\n" | |
| 694 " \"blacklist\": [\n" | |
| 695 " \"webgl\"\n" | |
| 696 " ]\n" | |
| 697 " }\n" | |
| 698 " ]\n" | |
| 699 "}"; | |
| 700 | |
| 701 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 702 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); | |
| 703 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 704 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 705 EXPECT_EQ(0, type); | |
| 706 } | |
| 707 | |
| 708 TEST_F(GpuBlacklistTest, PerfOverall) { | |
| 709 const std::string json = | |
| 710 "{\n" | |
| 711 " \"name\": \"gpu blacklist\",\n" | |
| 712 " \"version\": \"0.1\",\n" | |
| 713 " \"entries\": [\n" | |
| 714 " {\n" | |
| 715 " \"id\": 1,\n" | |
| 716 " \"perf_overall\": {\n" | |
| 717 " \"op\": \"between\",\n" | |
| 718 " \"value\": \"1.0\",\n" | |
| 719 " \"value2\": \"9.0\"\n" | |
| 720 " },\n" | |
| 721 " \"blacklist\": [\n" | |
| 722 " \"webgl\"\n" | |
| 723 " ]\n" | |
| 724 " }\n" | |
| 725 " ]\n" | |
| 726 "}"; | |
| 727 | |
| 728 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 729 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); | |
| 730 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 731 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 732 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 733 } | |
| 734 | |
| 735 TEST_F(GpuBlacklistTest, DisabledEntry) { | |
| 736 const std::string disabled_json = | |
| 737 "{\n" | |
| 738 " \"name\": \"gpu blacklist\",\n" | |
| 739 " \"version\": \"0.1\",\n" | |
| 740 " \"entries\": [\n" | |
| 741 " {\n" | |
| 742 " \"id\": 1,\n" | |
| 743 " \"disabled\": true,\n" | |
| 744 " \"blacklist\": [\n" | |
| 745 " \"webgl\"\n" | |
| 746 " ]\n" | |
| 747 " }\n" | |
| 748 " ]\n" | |
| 749 "}"; | |
| 750 | |
| 751 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 752 EXPECT_TRUE(blacklist->LoadGpuBlacklist(disabled_json, GpuBlacklist::kAllOs)); | |
| 753 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 754 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).blacklisted_features; | |
| 755 EXPECT_EQ(type, 0); | |
| 756 std::vector<uint32> flag_entries; | |
| 757 blacklist->GetDecisionEntries(&flag_entries, false); | |
| 758 EXPECT_EQ(0u, flag_entries.size()); | |
| 759 blacklist->GetDecisionEntries(&flag_entries, true); | |
| 760 EXPECT_EQ(1u, flag_entries.size()); | |
| 761 } | |
| 762 | |
| 763 TEST_F(GpuBlacklistTest, Optimus) { | |
| 764 const std::string optimus_json = | |
| 765 "{\n" | |
| 766 " \"name\": \"gpu blacklist\",\n" | |
| 767 " \"version\": \"0.1\",\n" | |
| 768 " \"entries\": [\n" | |
| 769 " {\n" | |
| 770 " \"id\": 1,\n" | |
| 771 " \"os\": {\n" | |
| 772 " \"type\": \"linux\"\n" | |
| 773 " },\n" | |
| 774 " \"multi_gpu_style\": \"optimus\",\n" | |
| 775 " \"blacklist\": [\n" | |
| 776 " \"webgl\"\n" | |
| 777 " ]\n" | |
| 778 " }\n" | |
| 779 " ]\n" | |
| 780 "}"; | |
| 781 | |
| 782 GPUInfo gpu_info; | |
| 783 gpu_info.optimus = true; | |
| 784 | |
| 785 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 786 EXPECT_TRUE(blacklist->LoadGpuBlacklist(optimus_json, GpuBlacklist::kAllOs)); | |
| 787 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 788 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 789 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 790 } | |
| 791 | |
| 792 TEST_F(GpuBlacklistTest, AMDSwitchable) { | |
| 793 const std::string amd_switchable_json = | |
| 794 "{\n" | |
| 795 " \"name\": \"gpu blacklist\",\n" | |
| 796 " \"version\": \"0.1\",\n" | |
| 797 " \"entries\": [\n" | |
| 798 " {\n" | |
| 799 " \"id\": 1,\n" | |
| 800 " \"os\": {\n" | |
| 801 " \"type\": \"macosx\"\n" | |
| 802 " },\n" | |
| 803 " \"multi_gpu_style\": \"amd_switchable\",\n" | |
| 804 " \"blacklist\": [\n" | |
| 805 " \"webgl\"\n" | |
| 806 " ]\n" | |
| 807 " }\n" | |
| 808 " ]\n" | |
| 809 "}"; | |
| 810 | |
| 811 GPUInfo gpu_info; | |
| 812 gpu_info.amd_switchable = true; | |
| 813 | |
| 814 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 815 EXPECT_TRUE(blacklist->LoadGpuBlacklist(amd_switchable_json, | |
| 816 GpuBlacklist::kAllOs)); | |
| 817 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 818 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 819 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 820 } | |
| 821 | |
| 822 TEST_F(GpuBlacklistTest, LexicalDriverVersion) { | |
| 823 const std::string lexical_json = | |
| 824 "{\n" | |
| 825 " \"name\": \"gpu blacklist\",\n" | |
| 826 " \"version\": \"0.1\",\n" | |
| 827 " \"entries\": [\n" | |
| 828 " {\n" | |
| 829 " \"id\": 1,\n" | |
| 830 " \"os\": {\n" | |
| 831 " \"type\": \"linux\"\n" | |
| 832 " },\n" | |
| 833 " \"vendor_id\": \"0x1002\",\n" | |
| 834 " \"driver_version\": {\n" | |
| 835 " \"op\": \"<\",\n" | |
| 836 " \"style\": \"lexical\",\n" | |
| 837 " \"number\": \"8.201\"\n" | |
| 838 " },\n" | |
| 839 " \"blacklist\": [\n" | |
| 840 " \"webgl\"\n" | |
| 841 " ]\n" | |
| 842 " }\n" | |
| 843 " ]\n" | |
| 844 "}"; | |
| 845 | |
| 846 GPUInfo gpu_info; | |
| 847 gpu_info.gpu.vendor_id = 0x1002; | |
| 848 | |
| 849 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 850 EXPECT_TRUE(blacklist->LoadGpuBlacklist(lexical_json, GpuBlacklist::kAllOs)); | |
| 851 | |
| 852 gpu_info.driver_version = "8.001.100"; | |
| 853 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 854 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 855 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 856 | |
| 857 gpu_info.driver_version = "8.109"; | |
| 858 type = blacklist->MakeBlacklistDecision( | |
| 859 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 860 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 861 | |
| 862 gpu_info.driver_version = "8.10900"; | |
| 863 type = blacklist->MakeBlacklistDecision( | |
| 864 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 865 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 866 | |
| 867 gpu_info.driver_version = "8.109.100"; | |
| 868 type = blacklist->MakeBlacklistDecision( | |
| 869 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 870 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 871 | |
| 872 gpu_info.driver_version = "8.2"; | |
| 873 type = blacklist->MakeBlacklistDecision( | |
| 874 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 875 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 876 | |
| 877 gpu_info.driver_version = "8.20"; | |
| 878 type = blacklist->MakeBlacklistDecision( | |
| 879 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 880 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 881 | |
| 882 gpu_info.driver_version = "8.200"; | |
| 883 type = blacklist->MakeBlacklistDecision( | |
| 884 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 885 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 886 | |
| 887 gpu_info.driver_version = "8.20.100"; | |
| 888 type = blacklist->MakeBlacklistDecision( | |
| 889 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 890 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 891 | |
| 892 gpu_info.driver_version = "8.201"; | |
| 893 type = blacklist->MakeBlacklistDecision( | |
| 894 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 895 EXPECT_EQ(0, type); | |
| 896 | |
| 897 gpu_info.driver_version = "8.2010"; | |
| 898 type = blacklist->MakeBlacklistDecision( | |
| 899 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 900 EXPECT_EQ(0, type); | |
| 901 | |
| 902 gpu_info.driver_version = "8.21"; | |
| 903 type = blacklist->MakeBlacklistDecision( | |
| 904 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 905 EXPECT_EQ(0, type); | |
| 906 | |
| 907 gpu_info.driver_version = "8.21.100"; | |
| 908 type = blacklist->MakeBlacklistDecision( | |
| 909 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 910 EXPECT_EQ(0, type); | |
| 911 | |
| 912 gpu_info.driver_version = "9.002"; | |
| 913 type = blacklist->MakeBlacklistDecision( | |
| 914 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 915 EXPECT_EQ(0, type); | |
| 916 | |
| 917 gpu_info.driver_version = "9.201"; | |
| 918 type = blacklist->MakeBlacklistDecision( | |
| 919 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 920 EXPECT_EQ(0, type); | |
| 921 | |
| 922 gpu_info.driver_version = "12"; | |
| 923 type = blacklist->MakeBlacklistDecision( | |
| 924 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 925 EXPECT_EQ(0, type); | |
| 926 | |
| 927 gpu_info.driver_version = "12.201"; | |
| 928 type = blacklist->MakeBlacklistDecision( | |
| 929 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 930 EXPECT_EQ(0, type); | |
| 931 } | |
| 932 | |
| 933 TEST_F(GpuBlacklistTest, LexicalDriverVersion2) { | |
| 934 const std::string lexical_json = | |
| 935 "{\n" | |
| 936 " \"name\": \"gpu blacklist\",\n" | |
| 937 " \"version\": \"0.1\",\n" | |
| 938 " \"entries\": [\n" | |
| 939 " {\n" | |
| 940 " \"id\": 1,\n" | |
| 941 " \"os\": {\n" | |
| 942 " \"type\": \"linux\"\n" | |
| 943 " },\n" | |
| 944 " \"vendor_id\": \"0x1002\",\n" | |
| 945 " \"driver_version\": {\n" | |
| 946 " \"op\": \"<\",\n" | |
| 947 " \"style\": \"lexical\",\n" | |
| 948 " \"number\": \"9.002\"\n" | |
| 949 " },\n" | |
| 950 " \"blacklist\": [\n" | |
| 951 " \"webgl\"\n" | |
| 952 " ]\n" | |
| 953 " }\n" | |
| 954 " ]\n" | |
| 955 "}"; | |
| 956 | |
| 957 GPUInfo gpu_info; | |
| 958 gpu_info.gpu.vendor_id = 0x1002; | |
| 959 | |
| 960 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 961 EXPECT_TRUE(blacklist->LoadGpuBlacklist(lexical_json, GpuBlacklist::kAllOs)); | |
| 962 | |
| 963 gpu_info.driver_version = "8.001.100"; | |
| 964 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 965 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 966 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 967 | |
| 968 gpu_info.driver_version = "8.109"; | |
| 969 type = blacklist->MakeBlacklistDecision( | |
| 970 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 971 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 972 | |
| 973 gpu_info.driver_version = "8.10900"; | |
| 974 type = blacklist->MakeBlacklistDecision( | |
| 975 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 976 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 977 | |
| 978 gpu_info.driver_version = "8.109.100"; | |
| 979 type = blacklist->MakeBlacklistDecision( | |
| 980 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 981 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 982 | |
| 983 gpu_info.driver_version = "8.2"; | |
| 984 type = blacklist->MakeBlacklistDecision( | |
| 985 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 986 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 987 | |
| 988 gpu_info.driver_version = "8.20"; | |
| 989 type = blacklist->MakeBlacklistDecision( | |
| 990 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 991 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 992 | |
| 993 gpu_info.driver_version = "8.200"; | |
| 994 type = blacklist->MakeBlacklistDecision( | |
| 995 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 996 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 997 | |
| 998 gpu_info.driver_version = "8.20.100"; | |
| 999 type = blacklist->MakeBlacklistDecision( | |
| 1000 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1001 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1002 | |
| 1003 gpu_info.driver_version = "8.201"; | |
| 1004 type = blacklist->MakeBlacklistDecision( | |
| 1005 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1006 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1007 | |
| 1008 gpu_info.driver_version = "8.2010"; | |
| 1009 type = blacklist->MakeBlacklistDecision( | |
| 1010 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1011 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1012 | |
| 1013 gpu_info.driver_version = "8.21"; | |
| 1014 type = blacklist->MakeBlacklistDecision( | |
| 1015 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1016 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1017 | |
| 1018 gpu_info.driver_version = "8.21.100"; | |
| 1019 type = blacklist->MakeBlacklistDecision( | |
| 1020 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1021 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1022 | |
| 1023 gpu_info.driver_version = "9.002"; | |
| 1024 type = blacklist->MakeBlacklistDecision( | |
| 1025 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1026 EXPECT_EQ(0, type); | |
| 1027 | |
| 1028 gpu_info.driver_version = "9.201"; | |
| 1029 type = blacklist->MakeBlacklistDecision( | |
| 1030 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1031 EXPECT_EQ(0, type); | |
| 1032 | |
| 1033 gpu_info.driver_version = "12"; | |
| 1034 type = blacklist->MakeBlacklistDecision( | |
| 1035 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1036 EXPECT_EQ(0, type); | |
| 1037 | |
| 1038 gpu_info.driver_version = "12.201"; | |
| 1039 type = blacklist->MakeBlacklistDecision( | |
| 1040 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1041 EXPECT_EQ(0, type); | |
| 1042 } | |
| 1043 | |
| 1044 TEST_F(GpuBlacklistTest, LexicalDriverVersion3) { | |
| 1045 const std::string lexical_json = | |
| 1046 "{\n" | |
| 1047 " \"name\": \"gpu blacklist\",\n" | |
| 1048 " \"version\": \"0.1\",\n" | |
| 1049 " \"entries\": [\n" | |
| 1050 " {\n" | |
| 1051 " \"id\": 1,\n" | |
| 1052 " \"os\": {\n" | |
| 1053 " \"type\": \"linux\"\n" | |
| 1054 " },\n" | |
| 1055 " \"vendor_id\": \"0x1002\",\n" | |
| 1056 " \"driver_version\": {\n" | |
| 1057 " \"op\": \"=\",\n" | |
| 1058 " \"style\": \"lexical\",\n" | |
| 1059 " \"number\": \"8.76\"\n" | |
| 1060 " },\n" | |
| 1061 " \"blacklist\": [\n" | |
| 1062 " \"webgl\"\n" | |
| 1063 " ]\n" | |
| 1064 " }\n" | |
| 1065 " ]\n" | |
| 1066 "}"; | |
| 1067 | |
| 1068 GPUInfo gpu_info; | |
| 1069 gpu_info.gpu.vendor_id = 0x1002; | |
| 1070 | |
| 1071 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1072 EXPECT_TRUE(blacklist->LoadGpuBlacklist(lexical_json, GpuBlacklist::kAllOs)); | |
| 1073 | |
| 1074 gpu_info.driver_version = "8.76"; | |
| 1075 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1076 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1077 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1078 | |
| 1079 gpu_info.driver_version = "8.768"; | |
| 1080 type = blacklist->MakeBlacklistDecision( | |
| 1081 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1082 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1083 | |
| 1084 gpu_info.driver_version = "8.76.8"; | |
| 1085 type = blacklist->MakeBlacklistDecision( | |
| 1086 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1087 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1088 } | |
| 1089 | |
| 1090 TEST_F(GpuBlacklistTest, MultipleGPUsAny) { | |
| 1091 const std::string multi_gpu_json = | |
| 1092 "{\n" | |
| 1093 " \"name\": \"gpu blacklist\",\n" | |
| 1094 " \"version\": \"0.1\",\n" | |
| 1095 " \"entries\": [\n" | |
| 1096 " {\n" | |
| 1097 " \"id\": 1,\n" | |
| 1098 " \"os\": {\n" | |
| 1099 " \"type\": \"macosx\"\n" | |
| 1100 " },\n" | |
| 1101 " \"vendor_id\": \"0x8086\",\n" | |
| 1102 " \"device_id\": [\"0x0166\"],\n" | |
| 1103 " \"multi_gpu_category\": \"any\",\n" | |
| 1104 " \"blacklist\": [\n" | |
| 1105 " \"webgl\"\n" | |
| 1106 " ]\n" | |
| 1107 " }\n" | |
| 1108 " ]\n" | |
| 1109 "}"; | |
| 1110 | |
| 1111 GPUInfo gpu_info; | |
| 1112 gpu_info.gpu.vendor_id = kNvidiaVendorId; | |
| 1113 gpu_info.gpu.device_id = kNvidiaDeviceId; | |
| 1114 | |
| 1115 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1116 EXPECT_TRUE(blacklist->LoadGpuBlacklist(multi_gpu_json, | |
| 1117 GpuBlacklist::kAllOs)); | |
| 1118 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1119 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 1120 EXPECT_EQ(0, type); | |
| 1121 | |
| 1122 GPUInfo::GPUDevice gpu_device; | |
| 1123 gpu_device.vendor_id = kIntelVendorId; | |
| 1124 gpu_device.device_id = kIntelDeviceId; | |
| 1125 gpu_info.secondary_gpus.push_back(gpu_device); | |
| 1126 type = blacklist->MakeBlacklistDecision( | |
| 1127 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 1128 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1129 } | |
| 1130 | |
| 1131 TEST_F(GpuBlacklistTest, MultipleGPUsSecondary) { | |
| 1132 const std::string multi_gpu_json = | |
| 1133 "{\n" | |
| 1134 " \"name\": \"gpu blacklist\",\n" | |
| 1135 " \"version\": \"0.1\",\n" | |
| 1136 " \"entries\": [\n" | |
| 1137 " {\n" | |
| 1138 " \"id\": 1,\n" | |
| 1139 " \"os\": {\n" | |
| 1140 " \"type\": \"macosx\"\n" | |
| 1141 " },\n" | |
| 1142 " \"vendor_id\": \"0x8086\",\n" | |
| 1143 " \"device_id\": [\"0x0166\"],\n" | |
| 1144 " \"multi_gpu_category\": \"secondary\",\n" | |
| 1145 " \"blacklist\": [\n" | |
| 1146 " \"webgl\"\n" | |
| 1147 " ]\n" | |
| 1148 " }\n" | |
| 1149 " ]\n" | |
| 1150 "}"; | |
| 1151 | |
| 1152 GPUInfo gpu_info; | |
| 1153 gpu_info.gpu.vendor_id = kNvidiaVendorId; | |
| 1154 gpu_info.gpu.device_id = kNvidiaDeviceId; | |
| 1155 | |
| 1156 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1157 EXPECT_TRUE(blacklist->LoadGpuBlacklist(multi_gpu_json, | |
| 1158 GpuBlacklist::kAllOs)); | |
| 1159 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1160 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 1161 EXPECT_EQ(0, type); | |
| 1162 | |
| 1163 GPUInfo::GPUDevice gpu_device; | |
| 1164 gpu_device.vendor_id = kIntelVendorId; | |
| 1165 gpu_device.device_id = kIntelDeviceId; | |
| 1166 gpu_info.secondary_gpus.push_back(gpu_device); | |
| 1167 type = blacklist->MakeBlacklistDecision( | |
| 1168 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 1169 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1170 } | |
| 1171 | |
| 1172 TEST_F(GpuBlacklistTest, GpuSwitching) { | |
| 1173 const std::string gpu_switching_json = | |
| 1174 "{\n" | |
| 1175 " \"name\": \"gpu blacklist\",\n" | |
| 1176 " \"version\": \"0.1\",\n" | |
| 1177 " \"entries\": [\n" | |
| 1178 " {\n" | |
| 1179 " \"id\": 1,\n" | |
| 1180 " \"os\": {\n" | |
| 1181 " \"type\": \"macosx\"\n" | |
| 1182 " },\n" | |
| 1183 " \"gpu_switching\": \"force_discrete\"\n" | |
| 1184 " },\n" | |
| 1185 " {\n" | |
| 1186 " \"id\": 2,\n" | |
| 1187 " \"os\": {\n" | |
| 1188 " \"type\": \"win\"\n" | |
| 1189 " },\n" | |
| 1190 " \"gpu_switching\": \"force_integrated\"\n" | |
| 1191 " },\n" | |
| 1192 " {\n" | |
| 1193 " \"id\": 3,\n" | |
| 1194 " \"os\": {\n" | |
| 1195 " \"type\": \"linux\"\n" | |
| 1196 " },\n" | |
| 1197 " \"gpu_switching\": \"automatic\"\n" | |
| 1198 " }\n" | |
| 1199 " ]\n" | |
| 1200 "}"; | |
| 1201 | |
| 1202 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1203 EXPECT_TRUE(blacklist->LoadGpuBlacklist(gpu_switching_json, | |
| 1204 GpuBlacklist::kAllOs)); | |
| 1205 GpuSwitchingOption switching = blacklist->MakeBlacklistDecision( | |
| 1206 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).gpu_switching; | |
| 1207 EXPECT_EQ(GPU_SWITCHING_OPTION_FORCE_DISCRETE, switching); | |
| 1208 std::vector<uint32> entries; | |
| 1209 blacklist->GetDecisionEntries(&entries, false); | |
| 1210 ASSERT_EQ(1u, entries.size()); | |
| 1211 EXPECT_EQ(1u, entries[0]); | |
| 1212 | |
| 1213 blacklist.reset(Create()); | |
| 1214 EXPECT_TRUE(blacklist->LoadGpuBlacklist(gpu_switching_json, | |
| 1215 GpuBlacklist::kAllOs)); | |
| 1216 switching = blacklist->MakeBlacklistDecision( | |
| 1217 GpuBlacklist::kOsWin, kOsVersion, gpu_info()).gpu_switching; | |
| 1218 EXPECT_EQ(GPU_SWITCHING_OPTION_FORCE_INTEGRATED, switching); | |
| 1219 blacklist->GetDecisionEntries(&entries, false); | |
| 1220 ASSERT_EQ(1u, entries.size()); | |
| 1221 EXPECT_EQ(2u, entries[0]); | |
| 1222 | |
| 1223 blacklist.reset(Create()); | |
| 1224 EXPECT_TRUE(blacklist->LoadGpuBlacklist(gpu_switching_json, | |
| 1225 GpuBlacklist::kAllOs)); | |
| 1226 switching = blacklist->MakeBlacklistDecision( | |
| 1227 GpuBlacklist::kOsLinux, kOsVersion, gpu_info()).gpu_switching; | |
| 1228 EXPECT_EQ(GPU_SWITCHING_OPTION_AUTOMATIC, switching); | |
| 1229 blacklist->GetDecisionEntries(&entries, false); | |
| 1230 ASSERT_EQ(1u, entries.size()); | |
| 1231 EXPECT_EQ(3u, entries[0]); | |
| 1232 } | |
| 1233 | |
| 1234 TEST_F(GpuBlacklistTest, VideoDecode) { | |
| 1235 const std::string video_decode_json = | |
| 1236 "{\n" | |
| 1237 " \"name\": \"gpu blacklist\",\n" | |
| 1238 " \"version\": \"0.1\",\n" | |
| 1239 " \"entries\": [\n" | |
| 1240 " {\n" | |
| 1241 " \"id\": 1,\n" | |
| 1242 " \"os\": {\n" | |
| 1243 " \"type\": \"macosx\"\n" | |
| 1244 " },\n" | |
| 1245 " \"vendor_id\": \"0x10de\",\n" | |
| 1246 " \"device_id\": [\"0x0640\"],\n" | |
| 1247 " \"blacklist\": [\n" | |
| 1248 " \"accelerated_video_decode\"\n" | |
| 1249 " ]\n" | |
| 1250 " }\n" | |
| 1251 " ]\n" | |
| 1252 "}"; | |
| 1253 | |
| 1254 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1255 EXPECT_TRUE(blacklist->LoadGpuBlacklist(video_decode_json, | |
| 1256 GpuBlacklist::kAllOs)); | |
| 1257 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1258 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 1259 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE, type); | |
| 1260 } | |
| 1261 | |
| 1262 TEST_F(GpuBlacklistTest, DualGpuModel) { | |
| 1263 const std::string model_json = | |
| 1264 "{\n" | |
| 1265 " \"name\": \"gpu blacklist\",\n" | |
| 1266 " \"version\": \"0.1\",\n" | |
| 1267 " \"entries\": [\n" | |
| 1268 " {\n" | |
| 1269 " \"id\": 5,\n" | |
| 1270 " \"os\": {\n" | |
| 1271 " \"type\": \"macosx\",\n" | |
| 1272 " \"version\": {\n" | |
| 1273 " \"op\": \">=\",\n" | |
| 1274 " \"number\": \"10.7\"\n" | |
| 1275 " }\n" | |
| 1276 " },\n" | |
| 1277 " \"machine_model\": {\n" | |
| 1278 " \"name\": {\n" | |
| 1279 " \"op\": \"=\",\n" | |
| 1280 " \"value\": \"MacBookPro\"\n" | |
| 1281 " },\n" | |
| 1282 " \"version\": {\n" | |
| 1283 " \"op\": \"<\",\n" | |
| 1284 " \"number\": \"8\"\n" | |
| 1285 " }\n" | |
| 1286 " },\n" | |
| 1287 " \"gpu_count\": {\n" | |
| 1288 " \"op\": \"=\",\n" | |
| 1289 " \"value\": \"2\"\n" | |
| 1290 " },\n" | |
| 1291 " \"gpu_switching\": \"force_discrete\"\n" | |
| 1292 " }\n" | |
| 1293 " ]\n" | |
| 1294 "}"; | |
| 1295 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1296 EXPECT_TRUE(blacklist->LoadGpuBlacklist(model_json, GpuBlacklist::kAllOs)); | |
| 1297 // Insert a second GPU. | |
| 1298 GPUInfo gpu_info; | |
| 1299 gpu_info.secondary_gpus.push_back(GPUInfo::GPUDevice()); | |
| 1300 GpuSwitchingOption switching = blacklist->MakeBlacklistDecision( | |
| 1301 GpuBlacklist::kOsMacosx, "10.7.2", gpu_info).gpu_switching; | |
| 1302 EXPECT_EQ(GPU_SWITCHING_OPTION_FORCE_DISCRETE, switching); | |
| 1303 } | |
| 1304 | |
| 1305 TEST_F(GpuBlacklistTest, Css3D) { | |
| 1306 const std::string css_3d_json = | |
| 1307 "{\n" | |
| 1308 " \"name\": \"gpu blacklist\",\n" | |
| 1309 " \"version\": \"0.1\",\n" | |
| 1310 " \"entries\": [\n" | |
| 1311 " {\n" | |
| 1312 " \"id\": 1,\n" | |
| 1313 " \"os\": {\n" | |
| 1314 " \"type\": \"macosx\"\n" | |
| 1315 " },\n" | |
| 1316 " \"vendor_id\": \"0x10de\",\n" | |
| 1317 " \"device_id\": [\"0x0640\"],\n" | |
| 1318 " \"blacklist\": [\n" | |
| 1319 " \"3d_css\"\n" | |
| 1320 " ]\n" | |
| 1321 " }\n" | |
| 1322 " ]\n" | |
| 1323 "}"; | |
| 1324 | |
| 1325 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1326 EXPECT_TRUE(blacklist->LoadGpuBlacklist(css_3d_json, GpuBlacklist::kAllOs)); | |
| 1327 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1328 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 1329 EXPECT_EQ(GPU_FEATURE_TYPE_3D_CSS, type); | |
| 1330 } | |
| 1331 | |
| 1332 TEST_F(GpuBlacklistTest, Video) { | |
| 1333 const std::string video_json = | |
| 1334 "{\n" | |
| 1335 " \"name\": \"gpu blacklist\",\n" | |
| 1336 " \"version\": \"0.1\",\n" | |
| 1337 " \"entries\": [\n" | |
| 1338 " {\n" | |
| 1339 " \"id\": 1,\n" | |
| 1340 " \"os\": {\n" | |
| 1341 " \"type\": \"macosx\"\n" | |
| 1342 " },\n" | |
| 1343 " \"vendor_id\": \"0x10de\",\n" | |
| 1344 " \"device_id\": [\"0x0640\"],\n" | |
| 1345 " \"blacklist\": [\n" | |
| 1346 " \"accelerated_video\"\n" | |
| 1347 " ]\n" | |
| 1348 " }\n" | |
| 1349 " ]\n" | |
| 1350 "}"; | |
| 1351 | |
| 1352 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1353 EXPECT_TRUE(blacklist->LoadGpuBlacklist(video_json, GpuBlacklist::kAllOs)); | |
| 1354 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1355 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()).blacklisted_features; | |
| 1356 EXPECT_EQ(GPU_FEATURE_TYPE_ACCELERATED_VIDEO, type); | |
| 1357 } | |
| 1358 | |
| 1359 TEST_F(GpuBlacklistTest, NeedsMoreInfo) { | |
| 1360 const std::string json = | |
| 1361 "{\n" | |
| 1362 " \"name\": \"gpu blacklist\",\n" | |
| 1363 " \"version\": \"0.1\",\n" | |
| 1364 " \"entries\": [\n" | |
| 1365 " {\n" | |
| 1366 " \"id\": 1,\n" | |
| 1367 " \"os\": {\n" | |
| 1368 " \"type\": \"linux\"\n" | |
| 1369 " },\n" | |
| 1370 " \"vendor_id\": \"0x8086\",\n" | |
| 1371 " \"driver_version\": {\n" | |
| 1372 " \"op\": \"<\",\n" | |
| 1373 " \"number\": \"10.7\"\n" | |
| 1374 " },\n" | |
| 1375 " \"blacklist\": [\n" | |
| 1376 " \"webgl\"\n" | |
| 1377 " ]\n" | |
| 1378 " }\n" | |
| 1379 " ]\n" | |
| 1380 "}"; | |
| 1381 | |
| 1382 GPUInfo gpu_info; | |
| 1383 gpu_info.gpu.vendor_id = kIntelVendorId; | |
| 1384 | |
| 1385 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1386 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); | |
| 1387 | |
| 1388 // The case this entry does not apply. | |
| 1389 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1390 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 1391 EXPECT_EQ(0, type); | |
| 1392 EXPECT_FALSE(blacklist->needs_more_info()); | |
| 1393 | |
| 1394 // The case this entry might apply, but need more info. | |
| 1395 type = blacklist->MakeBlacklistDecision( | |
| 1396 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1397 EXPECT_EQ(0, type); | |
| 1398 EXPECT_TRUE(blacklist->needs_more_info()); | |
| 1399 | |
| 1400 // The case we have full info, and this entry applies. | |
| 1401 gpu_info.driver_version = "10.6"; | |
| 1402 type = blacklist->MakeBlacklistDecision( | |
| 1403 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1404 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1405 EXPECT_FALSE(blacklist->needs_more_info()); | |
| 1406 | |
| 1407 // The case we have full info, and this entry does not apply. | |
| 1408 gpu_info.driver_version = "10.8"; | |
| 1409 type = blacklist->MakeBlacklistDecision( | |
| 1410 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1411 EXPECT_EQ(0, type); | |
| 1412 EXPECT_FALSE(blacklist->needs_more_info()); | |
| 1413 } | |
| 1414 | |
| 1415 TEST_F(GpuBlacklistTest, NeedsMoreInfoForExceptions) { | |
| 1416 const std::string json = | |
| 1417 "{\n" | |
| 1418 " \"name\": \"gpu blacklist\",\n" | |
| 1419 " \"version\": \"0.1\",\n" | |
| 1420 " \"entries\": [\n" | |
| 1421 " {\n" | |
| 1422 " \"id\": 1,\n" | |
| 1423 " \"os\": {\n" | |
| 1424 " \"type\": \"linux\"\n" | |
| 1425 " },\n" | |
| 1426 " \"vendor_id\": \"0x8086\",\n" | |
| 1427 " \"exceptions\": [\n" | |
| 1428 " {\n" | |
| 1429 " \"gl_renderer\": {\n" | |
| 1430 " \"op\": \"contains\",\n" | |
| 1431 " \"value\": \"mesa\"\n" | |
| 1432 " }\n" | |
| 1433 " }\n" | |
| 1434 " ],\n" | |
| 1435 " \"blacklist\": [\n" | |
| 1436 " \"webgl\"\n" | |
| 1437 " ]\n" | |
| 1438 " }\n" | |
| 1439 " ]\n" | |
| 1440 "}"; | |
| 1441 | |
| 1442 GPUInfo gpu_info; | |
| 1443 gpu_info.gpu.vendor_id = kIntelVendorId; | |
| 1444 | |
| 1445 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1446 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); | |
| 1447 | |
| 1448 // The case this entry does not apply. | |
| 1449 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1450 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info).blacklisted_features; | |
| 1451 EXPECT_EQ(0, type); | |
| 1452 EXPECT_FALSE(blacklist->needs_more_info()); | |
| 1453 | |
| 1454 // The case this entry might apply, but need more info. | |
| 1455 type = blacklist->MakeBlacklistDecision( | |
| 1456 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1457 EXPECT_EQ(0, type); | |
| 1458 EXPECT_TRUE(blacklist->needs_more_info()); | |
| 1459 | |
| 1460 // The case we have full info, and the exception applies (so the entry | |
| 1461 // does not apply). | |
| 1462 gpu_info.gl_renderer = "mesa"; | |
| 1463 type = blacklist->MakeBlacklistDecision( | |
| 1464 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1465 EXPECT_EQ(0, type); | |
| 1466 EXPECT_FALSE(blacklist->needs_more_info()); | |
| 1467 | |
| 1468 // The case we have full info, and this entry applies. | |
| 1469 gpu_info.gl_renderer = "my renderer"; | |
| 1470 type = blacklist->MakeBlacklistDecision(GpuBlacklist::kOsLinux, kOsVersion, | |
| 1471 gpu_info).blacklisted_features; | |
| 1472 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1473 EXPECT_FALSE(blacklist->needs_more_info()); | |
| 1474 } | |
| 1475 | |
| 1476 TEST_F(GpuBlacklistTest, IgnorableEntries) { | |
| 1477 // If an entry will not change the blacklist decisions, then it should not | |
| 1478 // trigger the needs_more_info flag. | |
| 1479 const std::string json = | |
| 1480 "{\n" | |
| 1481 " \"name\": \"gpu blacklist\",\n" | |
| 1482 " \"version\": \"0.1\",\n" | |
| 1483 " \"entries\": [\n" | |
| 1484 " {\n" | |
| 1485 " \"id\": 1,\n" | |
| 1486 " \"os\": {\n" | |
| 1487 " \"type\": \"linux\"\n" | |
| 1488 " },\n" | |
| 1489 " \"vendor_id\": \"0x8086\",\n" | |
| 1490 " \"blacklist\": [\n" | |
| 1491 " \"webgl\"\n" | |
| 1492 " ]\n" | |
| 1493 " },\n" | |
| 1494 " {\n" | |
| 1495 " \"id\": 2,\n" | |
| 1496 " \"os\": {\n" | |
| 1497 " \"type\": \"linux\"\n" | |
| 1498 " },\n" | |
| 1499 " \"vendor_id\": \"0x8086\",\n" | |
| 1500 " \"driver_version\": {\n" | |
| 1501 " \"op\": \"<\",\n" | |
| 1502 " \"number\": \"10.7\"\n" | |
| 1503 " },\n" | |
| 1504 " \"blacklist\": [\n" | |
| 1505 " \"webgl\"\n" | |
| 1506 " ]\n" | |
| 1507 " }\n" | |
| 1508 " ]\n" | |
| 1509 "}"; | |
| 1510 | |
| 1511 GPUInfo gpu_info; | |
| 1512 gpu_info.gpu.vendor_id = kIntelVendorId; | |
| 1513 | |
| 1514 scoped_ptr<GpuBlacklist> blacklist(Create()); | |
| 1515 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); | |
| 1516 GpuFeatureType type = blacklist->MakeBlacklistDecision( | |
| 1517 GpuBlacklist::kOsLinux, kOsVersion, gpu_info).blacklisted_features; | |
| 1518 EXPECT_EQ(GPU_FEATURE_TYPE_WEBGL, type); | |
| 1519 EXPECT_FALSE(blacklist->needs_more_info()); | |
| 1520 } | |
| 1521 | 162 |
| 1522 } // namespace content | 163 } // namespace content |
| OLD | NEW |