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

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: Fixed the unittest issues. 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 "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_EQ(flags.flags(), 0u);
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, false));
37 flags = blacklist.DetermineGpuFeatureFlags(
38 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
39 EXPECT_EQ(flags.flags(), 0u);
40
41 // Blacklist accelerated_compositing with exact setting.
42 const std::string exact_list_json =
43 "{\n"
44 " \"name\": \"gpu blacklist\",\n"
45 " \"version\": \"0.1\",\n"
46 " \"entries\": [\n"
47 " {\n"
48 " \"os\": {\n"
49 " \"type\": \"macosx\",\n"
50 " \"version\": {\n"
51 " \"op\": \"=\",\n"
52 " \"number\": \"10.6.4\"\n"
53 " }\n"
54 " },\n"
55 " \"vendor_id\": \"0x10de\",\n"
56 " \"device_id\": \"0x0640\",\n"
57 " \"driver_version\": {\n"
58 " \"op\": \"=\",\n"
59 " \"number\": \"1.6.18\"\n"
60 " },\n"
61 " \"blacklist\": [\n"
62 " \"accelerated_compositing\"\n"
63 " ]\n"
64 " }\n"
65 " ]\n"
66 "}";
67 EXPECT_TRUE(blacklist.LoadGpuBlacklist(exact_list_json, false));
68 flags = blacklist.DetermineGpuFeatureFlags(
69 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
70 EXPECT_EQ(
71 flags.flags(),
72 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing));
73
74 // Invalid json input should not change the current blacklist settings.
75 const std::string invalid_json = "invalid";
76 EXPECT_FALSE(blacklist.LoadGpuBlacklist(invalid_json, false));
77 flags = blacklist.DetermineGpuFeatureFlags(
78 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
79 EXPECT_EQ(
80 flags.flags(),
81 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing));
82
83 // Blacklist a vendor on all OS.
84 const std::string vendor_json =
85 "{\n"
86 " \"name\": \"gpu blacklist\",\n"
87 " \"version\": \"0.1\",\n"
88 " \"entries\": [\n"
89 " {\n"
90 " \"vendor_id\": \"0x10de\",\n"
91 " \"blacklist\": [\n"
92 " \"webgl\"\n"
93 " ]\n"
94 " }\n"
95 " ]\n"
96 "}";
97 EXPECT_TRUE(blacklist.LoadGpuBlacklist(vendor_json, false));
98 flags = blacklist.DetermineGpuFeatureFlags(
99 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
100 EXPECT_EQ(flags.flags(),
101 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
102 flags = blacklist.DetermineGpuFeatureFlags(
103 GpuBlacklist::kOsWin, os_version.get(), gpu_info);
104 EXPECT_EQ(flags.flags(),
105 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
106 flags = blacklist.DetermineGpuFeatureFlags(
107 GpuBlacklist::kOsLinux, os_version.get(), gpu_info);
108 EXPECT_EQ(flags.flags(),
109 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
110
111 // Blacklist a vendor on Linux only.
112 const std::string vendor_linux_json =
113 "{\n"
114 " \"name\": \"gpu blacklist\",\n"
115 " \"version\": \"0.1\",\n"
116 " \"entries\": [\n"
117 " {\n"
118 " \"os\": {\n"
119 " \"type\": \"linux\"\n"
120 " },\n"
121 " \"vendor_id\": \"0x10de\",\n"
122 " \"blacklist\": [\n"
123 " \"accelerated_2d_canvas\"\n"
124 " ]\n"
125 " }\n"
126 " ]\n"
127 "}";
128 EXPECT_TRUE(blacklist.LoadGpuBlacklist(vendor_linux_json, false));
129 flags = blacklist.DetermineGpuFeatureFlags(
130 GpuBlacklist::kOsMacosx, os_version.get(), gpu_info);
131 EXPECT_EQ(flags.flags(), 0u);
132 flags = blacklist.DetermineGpuFeatureFlags(
133 GpuBlacklist::kOsWin, os_version.get(), gpu_info);
134 EXPECT_EQ(flags.flags(), 0u);
135 flags = blacklist.DetermineGpuFeatureFlags(
136 GpuBlacklist::kOsLinux, os_version.get(), gpu_info);
137 EXPECT_EQ(
138 flags.flags(),
139 static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas));
140 }
141
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698