Add ICU message format support
[chromium-blink-merge.git] / gpu / config / gpu_test_config_unittest.cc
blobe42a805b2d8c858f76a77297e79fc0fd7df6b757
1 // Copyright (c) 2012 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.
5 #include "gpu/config/gpu_info.h"
6 #include "gpu/config/gpu_test_config.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace gpu {
11 class GPUTestConfigTest : public testing::Test {
12 public:
13 GPUTestConfigTest() { }
15 ~GPUTestConfigTest() override {}
17 protected:
18 void SetUp() override {}
20 void TearDown() override {}
23 TEST_F(GPUTestConfigTest, EmptyValues) {
24 GPUTestConfig config;
25 EXPECT_EQ(GPUTestConfig::kOsUnknown, config.os());
26 EXPECT_EQ(0u, config.gpu_vendor().size());
27 EXPECT_EQ(0u, config.gpu_device_id());
28 EXPECT_EQ(GPUTestConfig::kBuildTypeUnknown, config.build_type());
29 EXPECT_EQ(GPUTestConfig::kAPIUnknown, config.api());
32 TEST_F(GPUTestConfigTest, SetGPUInfo) {
33 GPUInfo gpu_info;
34 gpu_info.gpu.vendor_id = 0x10de;
35 gpu_info.gpu.device_id = 0x0640;
36 GPUTestBotConfig config;
37 EXPECT_TRUE(config.SetGPUInfo(gpu_info));
38 EXPECT_EQ(1u, config.gpu_vendor().size());
39 EXPECT_EQ(gpu_info.gpu.vendor_id, config.gpu_vendor()[0]);
40 EXPECT_EQ(gpu_info.gpu.device_id, config.gpu_device_id());
42 gpu_info.gpu.vendor_id = 0x8086;
43 gpu_info.gpu.device_id = 0x0046;
44 EXPECT_TRUE(config.SetGPUInfo(gpu_info));
45 EXPECT_EQ(1u, config.gpu_vendor().size());
46 EXPECT_EQ(gpu_info.gpu.vendor_id, config.gpu_vendor()[0]);
47 EXPECT_EQ(gpu_info.gpu.device_id, config.gpu_device_id());
50 TEST_F(GPUTestConfigTest, IsValid) {
52 GPUTestConfig config;
53 config.set_gpu_device_id(0x0640);
54 EXPECT_FALSE(config.IsValid());
55 config.AddGPUVendor(0x10de);
56 EXPECT_TRUE(config.IsValid());
60 GPUTestBotConfig config;
61 config.set_build_type(GPUTestConfig::kBuildTypeRelease);
62 config.set_os(GPUTestConfig::kOsWin7);
63 config.set_gpu_device_id(0x0640);
64 EXPECT_FALSE(config.IsValid());
65 config.AddGPUVendor(0x10de);
66 EXPECT_TRUE(config.IsValid());
68 config.set_gpu_device_id(0);
69 EXPECT_FALSE(config.IsValid());
70 config.set_gpu_device_id(0x0640);
71 EXPECT_TRUE(config.IsValid());
73 config.set_os(GPUTestConfig::kOsWin);
74 EXPECT_FALSE(config.IsValid());
75 config.set_os(GPUTestConfig::kOsWin7 | GPUTestConfig::kOsWinXP);
76 EXPECT_FALSE(config.IsValid());
77 config.set_os(GPUTestConfig::kOsWin7);
78 EXPECT_TRUE(config.IsValid());
80 config.set_build_type(GPUTestConfig::kBuildTypeUnknown);
81 EXPECT_FALSE(config.IsValid());
82 config.set_build_type(GPUTestConfig::kBuildTypeRelease);
83 EXPECT_TRUE(config.IsValid());
87 TEST_F(GPUTestConfigTest, Matches) {
88 GPUTestBotConfig config;
89 config.set_os(GPUTestConfig::kOsWin7);
90 config.set_build_type(GPUTestConfig::kBuildTypeRelease);
91 config.AddGPUVendor(0x10de);
92 config.set_gpu_device_id(0x0640);
93 config.set_api(GPUTestConfig::kAPID3D11);
94 EXPECT_TRUE(config.IsValid());
96 { // os matching
97 GPUTestConfig config2;
98 EXPECT_TRUE(config.Matches(config2));
99 config2.set_os(GPUTestConfig::kOsWin);
100 EXPECT_TRUE(config.Matches(config2));
101 config2.set_os(GPUTestConfig::kOsWin7);
102 EXPECT_TRUE(config.Matches(config2));
103 config2.set_os(GPUTestConfig::kOsMac);
104 EXPECT_FALSE(config.Matches(config2));
105 config2.set_os(GPUTestConfig::kOsWin7 | GPUTestConfig::kOsLinux);
106 EXPECT_TRUE(config.Matches(config2));
109 { // gpu vendor matching
111 GPUTestConfig config2;
112 config2.AddGPUVendor(0x10de);
113 EXPECT_TRUE(config.Matches(config2));
114 config2.AddGPUVendor(0x1004);
115 EXPECT_TRUE(config.Matches(config2));
118 GPUTestConfig config2;
119 config2.AddGPUVendor(0x8086);
120 EXPECT_FALSE(config.Matches(config2));
124 { // build type matching
125 GPUTestConfig config2;
126 config2.set_build_type(GPUTestConfig::kBuildTypeRelease);
127 EXPECT_TRUE(config.Matches(config2));
128 config2.set_build_type(GPUTestConfig::kBuildTypeRelease |
129 GPUTestConfig::kBuildTypeDebug);
130 EXPECT_TRUE(config.Matches(config2));
131 config2.set_build_type(GPUTestConfig::kBuildTypeDebug);
132 EXPECT_FALSE(config.Matches(config2));
135 { // exact matching
136 GPUTestConfig config2;
137 config2.set_os(GPUTestConfig::kOsWin7);
138 config2.set_build_type(GPUTestConfig::kBuildTypeRelease);
139 config2.AddGPUVendor(0x10de);
140 config2.set_gpu_device_id(0x0640);
141 EXPECT_TRUE(config.Matches(config2));
142 config2.set_gpu_device_id(0x0641);
143 EXPECT_FALSE(config.Matches(config2));
146 { // api matching
148 GPUTestConfig config2;
149 config2.set_api(GPUTestConfig::kAPID3D11);
150 EXPECT_TRUE(config.Matches(config2));
151 config2.set_api(config2.api() | GPUTestConfig::kAPID3D9);
152 EXPECT_TRUE(config.Matches(config2));
155 GPUTestConfig config2;
156 config2.set_api(GPUTestConfig::kAPID3D9);
157 EXPECT_FALSE(config.Matches(config2));
162 TEST_F(GPUTestConfigTest, StringMatches) {
163 GPUTestBotConfig config;
164 config.set_os(GPUTestConfig::kOsWin7);
165 config.set_build_type(GPUTestConfig::kBuildTypeRelease);
166 config.AddGPUVendor(0x10de);
167 config.set_gpu_device_id(0x0640);
168 config.set_api(GPUTestConfig::kAPID3D11);
169 EXPECT_TRUE(config.IsValid());
171 EXPECT_TRUE(config.Matches(std::string()));
173 // os matching
174 EXPECT_TRUE(config.Matches("WIN"));
175 EXPECT_TRUE(config.Matches("WIN7"));
176 EXPECT_FALSE(config.Matches("MAC"));
177 EXPECT_TRUE(config.Matches("WIN7 LINUX"));
179 // gpu vendor matching
180 EXPECT_TRUE(config.Matches("NVIDIA"));
181 EXPECT_TRUE(config.Matches("NVIDIA AMD"));
182 EXPECT_FALSE(config.Matches("INTEL"));
184 // build type matching
185 EXPECT_TRUE(config.Matches("RELEASE"));
186 EXPECT_TRUE(config.Matches("RELEASE DEBUG"));
187 EXPECT_FALSE(config.Matches("DEBUG"));
189 // exact matching
190 EXPECT_TRUE(config.Matches("WIN7 RELEASE NVIDIA 0X0640"));
191 EXPECT_FALSE(config.Matches("WIN7 RELEASE NVIDIA 0X0641"));
193 // api matching
194 EXPECT_TRUE(config.Matches("D3D11"));
195 EXPECT_FALSE(config.Matches("D3D9 OPENGL GLES"));
198 TEST_F(GPUTestConfigTest, OverlapsWith) {
199 { // os
200 // win vs win7
201 GPUTestConfig config;
202 config.set_os(GPUTestConfig::kOsWin);
203 GPUTestConfig config2;
204 config2.set_os(GPUTestConfig::kOsWin7);
205 EXPECT_TRUE(config.OverlapsWith(config2));
206 EXPECT_TRUE(config2.OverlapsWith(config));
207 // win vs win7+linux
208 config2.set_os(GPUTestConfig::kOsWin7 | GPUTestConfig::kOsLinux);
209 EXPECT_TRUE(config.OverlapsWith(config2));
210 EXPECT_TRUE(config2.OverlapsWith(config));
211 // win vs mac
212 config2.set_os(GPUTestConfig::kOsMac);
213 EXPECT_FALSE(config.OverlapsWith(config2));
214 EXPECT_FALSE(config2.OverlapsWith(config));
215 // win vs unknown
216 config2.set_os(GPUTestConfig::kOsUnknown);
217 EXPECT_TRUE(config.OverlapsWith(config2));
218 EXPECT_TRUE(config2.OverlapsWith(config));
221 { // gpu vendor
222 GPUTestConfig config;
223 config.AddGPUVendor(0x10de);
224 // nvidia vs unknown
225 GPUTestConfig config2;
226 EXPECT_TRUE(config.OverlapsWith(config2));
227 EXPECT_TRUE(config2.OverlapsWith(config));
228 // nvidia vs intel
229 config2.AddGPUVendor(0x1086);
230 EXPECT_FALSE(config.OverlapsWith(config2));
231 EXPECT_FALSE(config2.OverlapsWith(config));
232 // nvidia vs nvidia+intel
233 config2.AddGPUVendor(0x10de);
234 EXPECT_TRUE(config.OverlapsWith(config2));
235 EXPECT_TRUE(config2.OverlapsWith(config));
238 { // build type
239 // release vs debug
240 GPUTestConfig config;
241 config.set_build_type(GPUTestConfig::kBuildTypeRelease);
242 GPUTestConfig config2;
243 config2.set_build_type(GPUTestConfig::kBuildTypeDebug);
244 EXPECT_FALSE(config.OverlapsWith(config2));
245 EXPECT_FALSE(config2.OverlapsWith(config));
246 // release vs release+debug
247 config2.set_build_type(GPUTestConfig::kBuildTypeRelease |
248 GPUTestConfig::kBuildTypeDebug);
249 EXPECT_TRUE(config.OverlapsWith(config2));
250 EXPECT_TRUE(config2.OverlapsWith(config));
251 // release vs unknown
252 config2.set_build_type(GPUTestConfig::kBuildTypeUnknown);
253 EXPECT_TRUE(config.OverlapsWith(config2));
254 EXPECT_TRUE(config2.OverlapsWith(config));
257 { // win7 vs nvidia
258 GPUTestConfig config;
259 config.set_os(GPUTestConfig::kOsWin7);
260 GPUTestConfig config2;
261 config2.AddGPUVendor(0x10de);
262 EXPECT_TRUE(config.OverlapsWith(config2));
263 EXPECT_TRUE(config2.OverlapsWith(config));
267 TEST_F(GPUTestConfigTest, LoadCurrentConfig) {
268 GPUTestBotConfig config;
269 GPUInfo gpu_info;
270 gpu_info.gpu.vendor_id = 0x10de;
271 gpu_info.gpu.device_id = 0x0640;
272 EXPECT_TRUE(config.LoadCurrentConfig(&gpu_info));
273 EXPECT_TRUE(config.IsValid());
276 } // namespace gpu