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 "gpu/config/gpu_blacklist.h" | 5 #include "gpu/config/gpu_blacklist.h" |
6 | |
7 #include <memory> | |
8 | |
9 #include "gpu/config/gpu_control_list_jsons.h" | |
10 #include "gpu/config/gpu_feature_type.h" | 6 #include "gpu/config/gpu_feature_type.h" |
11 #include "gpu/config/gpu_info.h" | 7 #include "gpu/config/gpu_info.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
13 | 9 |
14 const char kOsVersion[] = "10.6.4"; | |
15 | |
16 namespace gpu { | 10 namespace gpu { |
17 | 11 |
18 class GpuBlacklistTest : public testing::Test { | 12 class GpuBlacklistTest : public testing::Test { |
19 public: | 13 public: |
20 GpuBlacklistTest() { } | 14 GpuBlacklistTest() { } |
21 | |
22 ~GpuBlacklistTest() override {} | 15 ~GpuBlacklistTest() override {} |
23 | 16 |
24 const GPUInfo& gpu_info() const { | 17 const GPUInfo& gpu_info() const { |
25 return gpu_info_; | 18 return gpu_info_; |
26 } | 19 } |
27 | 20 |
28 void RunFeatureTest(const std::string& feature_name, | 21 void RunFeatureTest(GpuFeatureType feature_type) { |
29 GpuFeatureType feature_type) { | 22 const int kFeatureListForEntry1[1] = {feature_type}; |
30 const std::string json = | 23 const uint32_t kDeviceIDsForEntry1[1] = {0x0640}; |
31 "{\n" | 24 const GpuControlList::Entry kTestEntries[1] = {{ |
32 " \"name\": \"gpu blacklist\",\n" | 25 1, // id |
33 " \"version\": \"0.1\",\n" | 26 "Test entry", // description |
34 " \"entries\": [\n" | 27 1, // features size |
35 " {\n" | 28 kFeatureListForEntry1, // features |
36 " \"id\": 1,\n" | 29 0, // DisabledExtensions size |
37 " \"os\": {\n" | 30 nullptr, // DisabledExtensions |
38 " \"type\": \"macosx\"\n" | 31 0, // CrBugs size |
39 " },\n" | 32 nullptr, // CrBugs |
40 " \"vendor_id\": \"0x10de\",\n" | 33 { |
41 " \"device_id\": [\"0x0640\"],\n" | 34 GpuControlList::kOsMacosx, // os_type |
42 " \"features\": [\n" | 35 {GpuControlList::kUnknown, GpuControlList::kVersionStyleNumerical, |
43 " \"" + | 36 nullptr, nullptr}, // os_version |
44 feature_name + | 37 0x10de, // vendor_id |
45 "\"\n" | 38 1, // DeviceIDs size |
46 " ]\n" | 39 kDeviceIDsForEntry1, // DeviceIDs |
47 " }\n" | 40 GpuControlList::kMultiGpuCategoryAny, // multi_gpu_category |
48 " ]\n" | 41 GpuControlList::kMultiGpuStyleNone, // multi_gpu_style |
49 "}"; | 42 nullptr, // driver info |
50 | 43 nullptr, // GL strings |
51 std::unique_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create()); | 44 nullptr, // machine model info |
52 EXPECT_TRUE(blacklist->LoadList(json, GpuBlacklist::kAllOs)); | 45 nullptr, // more conditions |
53 std::set<int> type = blacklist->MakeDecision( | 46 }, |
54 GpuBlacklist::kOsMacosx, kOsVersion, gpu_info()); | 47 0, // exceptions count |
| 48 nullptr, // exceptions |
| 49 }}; |
| 50 GpuControlListData data("1.0", 1, kTestEntries); |
| 51 std::unique_ptr<GpuBlacklist> blacklist = GpuBlacklist::Create(data); |
| 52 std::set<int> type = |
| 53 blacklist->MakeDecision(GpuBlacklist::kOsMacosx, "10.12.3", gpu_info()); |
55 EXPECT_EQ(1u, type.size()); | 54 EXPECT_EQ(1u, type.size()); |
56 EXPECT_EQ(1u, type.count(feature_type)); | 55 EXPECT_EQ(1u, type.count(feature_type)); |
57 } | 56 } |
58 | 57 |
59 protected: | 58 protected: |
60 void SetUp() override { | 59 void SetUp() override { |
61 gpu_info_.gpu.vendor_id = 0x10de; | 60 gpu_info_.gpu.vendor_id = 0x10de; |
62 gpu_info_.gpu.device_id = 0x0640; | 61 gpu_info_.gpu.device_id = 0x0640; |
63 gpu_info_.driver_vendor = "NVIDIA"; | 62 gpu_info_.driver_vendor = "NVIDIA"; |
64 gpu_info_.driver_version = "1.6.18"; | 63 gpu_info_.driver_version = "1.6.18"; |
65 gpu_info_.driver_date = "7-14-2009"; | 64 gpu_info_.driver_date = "7-14-2009"; |
66 gpu_info_.machine_model_name = "MacBookPro"; | 65 gpu_info_.machine_model_name = "MacBookPro"; |
67 gpu_info_.machine_model_version = "7.1"; | 66 gpu_info_.machine_model_version = "7.1"; |
68 gpu_info_.gl_vendor = "NVIDIA Corporation"; | 67 gpu_info_.gl_vendor = "NVIDIA Corporation"; |
69 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; | 68 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; |
70 } | 69 } |
71 | 70 |
72 void TearDown() override {} | |
73 | |
74 private: | 71 private: |
75 GPUInfo gpu_info_; | 72 GPUInfo gpu_info_; |
76 }; | 73 }; |
77 | 74 |
78 TEST_F(GpuBlacklistTest, CurrentBlacklistValidation) { | 75 #define GPU_BLACKLIST_FEATURE_TEST(test_name, feature_type) \ |
79 std::unique_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create()); | 76 TEST_F(GpuBlacklistTest, test_name) { RunFeatureTest(feature_type); } |
80 EXPECT_TRUE(blacklist->LoadList( | |
81 kSoftwareRenderingListJson, GpuBlacklist::kAllOs)); | |
82 } | |
83 | |
84 TEST_F(GpuBlacklistTest, DuplicatedIDValidation) { | |
85 std::unique_ptr<GpuBlacklist> blacklist(GpuBlacklist::Create()); | |
86 EXPECT_TRUE(blacklist->LoadList( | |
87 kSoftwareRenderingListJson, GpuBlacklist::kAllOs)); | |
88 EXPECT_FALSE(blacklist->has_duplicated_entry_id()); | |
89 } | |
90 | |
91 #define GPU_BLACKLIST_FEATURE_TEST(test_name, feature_name, feature_type) \ | |
92 TEST_F(GpuBlacklistTest, test_name) { \ | |
93 RunFeatureTest(feature_name, feature_type); \ | |
94 } | |
95 | 77 |
96 GPU_BLACKLIST_FEATURE_TEST(Accelerated2DCanvas, | 78 GPU_BLACKLIST_FEATURE_TEST(Accelerated2DCanvas, |
97 "accelerated_2d_canvas", | |
98 GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) | 79 GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS) |
99 | 80 |
100 GPU_BLACKLIST_FEATURE_TEST(GpuCompositing, | 81 GPU_BLACKLIST_FEATURE_TEST(GpuCompositing, |
101 "gpu_compositing", | |
102 GPU_FEATURE_TYPE_GPU_COMPOSITING) | 82 GPU_FEATURE_TYPE_GPU_COMPOSITING) |
103 | 83 |
104 GPU_BLACKLIST_FEATURE_TEST(WebGL, | 84 GPU_BLACKLIST_FEATURE_TEST(AcceleratedWebGL, GPU_FEATURE_TYPE_ACCELERATED_WEBGL) |
105 "accelerated_webgl", | |
106 GPU_FEATURE_TYPE_ACCELERATED_WEBGL) | |
107 | 85 |
108 GPU_BLACKLIST_FEATURE_TEST(Flash3D, | 86 GPU_BLACKLIST_FEATURE_TEST(Flash3D, |
109 "flash_3d", | |
110 GPU_FEATURE_TYPE_FLASH3D) | 87 GPU_FEATURE_TYPE_FLASH3D) |
111 | 88 |
112 GPU_BLACKLIST_FEATURE_TEST(FlashStage3D, | 89 GPU_BLACKLIST_FEATURE_TEST(FlashStage3D, |
113 "flash_stage3d", | |
114 GPU_FEATURE_TYPE_FLASH_STAGE3D) | 90 GPU_FEATURE_TYPE_FLASH_STAGE3D) |
115 | 91 |
116 GPU_BLACKLIST_FEATURE_TEST(FlashStage3DBaseline, | 92 GPU_BLACKLIST_FEATURE_TEST(FlashStage3DBaseline, |
117 "flash_stage3d_baseline", | |
118 GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE) | 93 GPU_FEATURE_TYPE_FLASH_STAGE3D_BASELINE) |
119 | 94 |
120 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideoDecode, | 95 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideoDecode, |
121 "accelerated_video_decode", | |
122 GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) | 96 GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE) |
123 | 97 |
124 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideoEncode, | 98 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVideoEncode, |
125 "accelerated_video_encode", | |
126 GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) | 99 GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE) |
127 | 100 |
128 GPU_BLACKLIST_FEATURE_TEST(PanelFitting, | 101 GPU_BLACKLIST_FEATURE_TEST(PanelFitting, |
129 "panel_fitting", | |
130 GPU_FEATURE_TYPE_PANEL_FITTING) | 102 GPU_FEATURE_TYPE_PANEL_FITTING) |
131 | 103 |
132 GPU_BLACKLIST_FEATURE_TEST(GpuRasterization, | 104 GPU_BLACKLIST_FEATURE_TEST(GpuRasterization, |
133 "gpu_rasterization", | |
134 GPU_FEATURE_TYPE_GPU_RASTERIZATION) | 105 GPU_FEATURE_TYPE_GPU_RASTERIZATION) |
135 | 106 |
136 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVpxDecode, | 107 GPU_BLACKLIST_FEATURE_TEST(AcceleratedVpxDecode, |
137 "accelerated_vpx_decode", | |
138 GPU_FEATURE_TYPE_ACCELERATED_VPX_DECODE) | 108 GPU_FEATURE_TYPE_ACCELERATED_VPX_DECODE) |
139 | 109 |
140 GPU_BLACKLIST_FEATURE_TEST(WebGL2, | 110 GPU_BLACKLIST_FEATURE_TEST(WebGL2, |
141 "webgl2", | |
142 GPU_FEATURE_TYPE_WEBGL2) | 111 GPU_FEATURE_TYPE_WEBGL2) |
143 | 112 |
144 } // namespace gpu | 113 } // namespace gpu |
OLD | NEW |