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