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

Side by Side Diff: gpu/config/gpu_control_list_entry_unittest.cc

Issue 16293004: Update gpu/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months 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
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | gpu/config/gpu_info_collector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "gpu/config/gpu_control_list.h" 6 #include "gpu/config/gpu_control_list.h"
7 #include "gpu/config/gpu_info.h" 7 #include "gpu/config/gpu_info.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 #define LONG_STRING_CONST(...) #__VA_ARGS__ 10 #define LONG_STRING_CONST(...) #__VA_ARGS__
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 "op": "=", 87 "op": "=",
88 "number": "1.6.18" 88 "number": "1.6.18"
89 }, 89 },
90 "features": [ 90 "features": [
91 "test_feature_0" 91 "test_feature_0"
92 ] 92 ]
93 } 93 }
94 ); 94 );
95 95
96 ScopedEntry entry(GetEntryFromString(json)); 96 ScopedEntry entry(GetEntryFromString(json));
97 EXPECT_TRUE(entry != NULL); 97 EXPECT_TRUE(entry.get() != NULL);
98 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType()); 98 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
99 EXPECT_FALSE(entry->disabled()); 99 EXPECT_FALSE(entry->disabled());
100 EXPECT_EQ(5u, entry->id()); 100 EXPECT_EQ(5u, entry->id());
101 EXPECT_STREQ("test entry", entry->description().c_str()); 101 EXPECT_STREQ("test entry", entry->description().c_str());
102 EXPECT_EQ(2u, entry->cr_bugs().size()); 102 EXPECT_EQ(2u, entry->cr_bugs().size());
103 EXPECT_EQ(1024, entry->cr_bugs()[0]); 103 EXPECT_EQ(1024, entry->cr_bugs()[0]);
104 EXPECT_EQ(678, entry->cr_bugs()[1]); 104 EXPECT_EQ(678, entry->cr_bugs()[1]);
105 EXPECT_EQ(1u, entry->webkit_bugs().size()); 105 EXPECT_EQ(1u, entry->webkit_bugs().size());
106 EXPECT_EQ(1950, entry->webkit_bugs()[0]); 106 EXPECT_EQ(1950, entry->webkit_bugs()[0]);
107 EXPECT_EQ(1u, entry->features().size()); 107 EXPECT_EQ(1u, entry->features().size());
108 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0)); 108 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0));
109 EXPECT_FALSE(entry->contains_unknown_fields()); 109 EXPECT_FALSE(entry->contains_unknown_fields());
110 EXPECT_FALSE(entry->contains_unknown_features()); 110 EXPECT_FALSE(entry->contains_unknown_features());
111 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info())); 111 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info()));
112 EXPECT_TRUE(entry->Contains( 112 EXPECT_TRUE(entry->Contains(
113 GpuControlList::kOsMacosx, "10.6.4", gpu_info())); 113 GpuControlList::kOsMacosx, "10.6.4", gpu_info()));
114 } 114 }
115 115
116 TEST_F(GpuControlListEntryTest, VendorOnAllOsEntry) { 116 TEST_F(GpuControlListEntryTest, VendorOnAllOsEntry) {
117 const std::string json = LONG_STRING_CONST( 117 const std::string json = LONG_STRING_CONST(
118 { 118 {
119 "id": 1, 119 "id": 1,
120 "vendor_id": "0x10de", 120 "vendor_id": "0x10de",
121 "features": [ 121 "features": [
122 "test_feature_0" 122 "test_feature_0"
123 ] 123 ]
124 } 124 }
125 ); 125 );
126 ScopedEntry entry(GetEntryFromString(json)); 126 ScopedEntry entry(GetEntryFromString(json));
127 EXPECT_TRUE(entry != NULL); 127 EXPECT_TRUE(entry.get() != NULL);
128 EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType()); 128 EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType());
129 129
130 const GpuControlList::OsType os_type[] = { 130 const GpuControlList::OsType os_type[] = {
131 GpuControlList::kOsMacosx, 131 GpuControlList::kOsMacosx,
132 GpuControlList::kOsWin, 132 GpuControlList::kOsWin,
133 GpuControlList::kOsLinux, 133 GpuControlList::kOsLinux,
134 GpuControlList::kOsChromeOS, 134 GpuControlList::kOsChromeOS,
135 GpuControlList::kOsAndroid 135 GpuControlList::kOsAndroid
136 }; 136 };
137 for (size_t i = 0; i < arraysize(os_type); ++i) 137 for (size_t i = 0; i < arraysize(os_type); ++i)
138 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info())); 138 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info()));
139 } 139 }
140 140
141 TEST_F(GpuControlListEntryTest, VendorOnLinuxEntry) { 141 TEST_F(GpuControlListEntryTest, VendorOnLinuxEntry) {
142 const std::string json = LONG_STRING_CONST( 142 const std::string json = LONG_STRING_CONST(
143 { 143 {
144 "id": 1, 144 "id": 1,
145 "os": { 145 "os": {
146 "type": "linux" 146 "type": "linux"
147 }, 147 },
148 "vendor_id": "0x10de", 148 "vendor_id": "0x10de",
149 "features": [ 149 "features": [
150 "test_feature_0" 150 "test_feature_0"
151 ] 151 ]
152 } 152 }
153 ); 153 );
154 ScopedEntry entry(GetEntryFromString(json)); 154 ScopedEntry entry(GetEntryFromString(json));
155 EXPECT_TRUE(entry != NULL); 155 EXPECT_TRUE(entry.get() != NULL);
156 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType()); 156 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
157 157
158 const GpuControlList::OsType os_type[] = { 158 const GpuControlList::OsType os_type[] = {
159 GpuControlList::kOsMacosx, 159 GpuControlList::kOsMacosx,
160 GpuControlList::kOsWin, 160 GpuControlList::kOsWin,
161 GpuControlList::kOsChromeOS, 161 GpuControlList::kOsChromeOS,
162 GpuControlList::kOsAndroid 162 GpuControlList::kOsAndroid
163 }; 163 };
164 for (size_t i = 0; i < arraysize(os_type); ++i) 164 for (size_t i = 0; i < arraysize(os_type); ++i)
165 EXPECT_FALSE(entry->Contains(os_type[i], "10.6", gpu_info())); 165 EXPECT_FALSE(entry->Contains(os_type[i], "10.6", gpu_info()));
(...skipping 12 matching lines...) Expand all
178 { 178 {
179 "vendor_id": "0x10de" 179 "vendor_id": "0x10de"
180 } 180 }
181 ], 181 ],
182 "features": [ 182 "features": [
183 "test_feature_0" 183 "test_feature_0"
184 ] 184 ]
185 } 185 }
186 ); 186 );
187 ScopedEntry entry(GetEntryFromString(json)); 187 ScopedEntry entry(GetEntryFromString(json));
188 EXPECT_TRUE(entry != NULL); 188 EXPECT_TRUE(entry.get() != NULL);
189 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType()); 189 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
190 190
191 const GpuControlList::OsType os_type[] = { 191 const GpuControlList::OsType os_type[] = {
192 GpuControlList::kOsMacosx, 192 GpuControlList::kOsMacosx,
193 GpuControlList::kOsWin, 193 GpuControlList::kOsWin,
194 GpuControlList::kOsLinux, 194 GpuControlList::kOsLinux,
195 GpuControlList::kOsChromeOS, 195 GpuControlList::kOsChromeOS,
196 GpuControlList::kOsAndroid 196 GpuControlList::kOsAndroid
197 }; 197 };
198 for (size_t i = 0; i < arraysize(os_type); ++i) 198 for (size_t i = 0; i < arraysize(os_type); ++i)
(...skipping 11 matching lines...) Expand all
210 { 210 {
211 "vendor_id": "0x8086" 211 "vendor_id": "0x8086"
212 } 212 }
213 ], 213 ],
214 "features": [ 214 "features": [
215 "test_feature_0" 215 "test_feature_0"
216 ] 216 ]
217 } 217 }
218 ); 218 );
219 ScopedEntry entry(GetEntryFromString(json)); 219 ScopedEntry entry(GetEntryFromString(json));
220 EXPECT_TRUE(entry != NULL); 220 EXPECT_TRUE(entry.get() != NULL);
221 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType()); 221 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
222 222
223 const GpuControlList::OsType os_type[] = { 223 const GpuControlList::OsType os_type[] = {
224 GpuControlList::kOsMacosx, 224 GpuControlList::kOsMacosx,
225 GpuControlList::kOsWin, 225 GpuControlList::kOsWin,
226 GpuControlList::kOsChromeOS, 226 GpuControlList::kOsChromeOS,
227 GpuControlList::kOsAndroid 227 GpuControlList::kOsAndroid
228 }; 228 };
229 for (size_t i = 0; i < arraysize(os_type); ++i) 229 for (size_t i = 0; i < arraysize(os_type); ++i)
230 EXPECT_FALSE(entry->Contains(os_type[i], "10.6", gpu_info())); 230 EXPECT_FALSE(entry->Contains(os_type[i], "10.6", gpu_info()));
(...skipping 11 matching lines...) Expand all
242 "driver_date": { 242 "driver_date": {
243 "op": "<", 243 "op": "<",
244 "number": "2010.5.8" 244 "number": "2010.5.8"
245 }, 245 },
246 "features": [ 246 "features": [
247 "test_feature_0" 247 "test_feature_0"
248 ] 248 ]
249 } 249 }
250 ); 250 );
251 ScopedEntry entry(GetEntryFromString(json)); 251 ScopedEntry entry(GetEntryFromString(json));
252 EXPECT_TRUE(entry != NULL); 252 EXPECT_TRUE(entry.get() != NULL);
253 EXPECT_EQ(GpuControlList::kOsWin, entry->GetOsType()); 253 EXPECT_EQ(GpuControlList::kOsWin, entry->GetOsType());
254 254
255 GPUInfo gpu_info; 255 GPUInfo gpu_info;
256 gpu_info.driver_date = "4-12-2010"; 256 gpu_info.driver_date = "4-12-2010";
257 EXPECT_TRUE(entry->Contains( 257 EXPECT_TRUE(entry->Contains(
258 GpuControlList::kOsWin, "10.6", gpu_info)); 258 GpuControlList::kOsWin, "10.6", gpu_info));
259 gpu_info.driver_date = "5-8-2010"; 259 gpu_info.driver_date = "5-8-2010";
260 EXPECT_FALSE(entry->Contains( 260 EXPECT_FALSE(entry->Contains(
261 GpuControlList::kOsWin, "10.6", gpu_info)); 261 GpuControlList::kOsWin, "10.6", gpu_info));
262 gpu_info.driver_date = "5-9-2010"; 262 gpu_info.driver_date = "5-9-2010";
263 EXPECT_FALSE(entry->Contains( 263 EXPECT_FALSE(entry->Contains(
264 GpuControlList::kOsWin, "10.6", gpu_info)); 264 GpuControlList::kOsWin, "10.6", gpu_info));
265 } 265 }
266 266
267 TEST_F(GpuControlListEntryTest, MultipleDevicesEntry) { 267 TEST_F(GpuControlListEntryTest, MultipleDevicesEntry) {
268 const std::string json = LONG_STRING_CONST( 268 const std::string json = LONG_STRING_CONST(
269 { 269 {
270 "id": 1, 270 "id": 1,
271 "vendor_id": "0x10de", 271 "vendor_id": "0x10de",
272 "device_id": ["0x1023", "0x0640"], 272 "device_id": ["0x1023", "0x0640"],
273 "features": [ 273 "features": [
274 "test_feature_0" 274 "test_feature_0"
275 ] 275 ]
276 } 276 }
277 ); 277 );
278 ScopedEntry entry(GetEntryFromString(json)); 278 ScopedEntry entry(GetEntryFromString(json));
279 EXPECT_TRUE(entry != NULL); 279 EXPECT_TRUE(entry.get() != NULL);
280 EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType()); 280 EXPECT_EQ(GpuControlList::kOsAny, entry->GetOsType());
281 281
282 const GpuControlList::OsType os_type[] = { 282 const GpuControlList::OsType os_type[] = {
283 GpuControlList::kOsMacosx, 283 GpuControlList::kOsMacosx,
284 GpuControlList::kOsWin, 284 GpuControlList::kOsWin,
285 GpuControlList::kOsLinux, 285 GpuControlList::kOsLinux,
286 GpuControlList::kOsChromeOS, 286 GpuControlList::kOsChromeOS,
287 GpuControlList::kOsAndroid 287 GpuControlList::kOsAndroid
288 }; 288 };
289 for (size_t i = 0; i < arraysize(os_type); ++i) 289 for (size_t i = 0; i < arraysize(os_type); ++i)
290 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info())); 290 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info()));
291 } 291 }
292 292
293 TEST_F(GpuControlListEntryTest, ChromeOSEntry) { 293 TEST_F(GpuControlListEntryTest, ChromeOSEntry) {
294 const std::string json = LONG_STRING_CONST( 294 const std::string json = LONG_STRING_CONST(
295 { 295 {
296 "id": 1, 296 "id": 1,
297 "os": { 297 "os": {
298 "type": "chromeos" 298 "type": "chromeos"
299 }, 299 },
300 "features": [ 300 "features": [
301 "test_feature_0" 301 "test_feature_0"
302 ] 302 ]
303 } 303 }
304 ); 304 );
305 ScopedEntry entry(GetEntryFromString(json)); 305 ScopedEntry entry(GetEntryFromString(json));
306 EXPECT_TRUE(entry != NULL); 306 EXPECT_TRUE(entry.get() != NULL);
307 EXPECT_EQ(GpuControlList::kOsChromeOS, entry->GetOsType()); 307 EXPECT_EQ(GpuControlList::kOsChromeOS, entry->GetOsType());
308 308
309 const GpuControlList::OsType os_type[] = { 309 const GpuControlList::OsType os_type[] = {
310 GpuControlList::kOsMacosx, 310 GpuControlList::kOsMacosx,
311 GpuControlList::kOsWin, 311 GpuControlList::kOsWin,
312 GpuControlList::kOsLinux, 312 GpuControlList::kOsLinux,
313 GpuControlList::kOsAndroid 313 GpuControlList::kOsAndroid
314 }; 314 };
315 for (size_t i = 0; i < arraysize(os_type); ++i) 315 for (size_t i = 0; i < arraysize(os_type); ++i)
316 EXPECT_FALSE(entry->Contains(os_type[i], "10.6", gpu_info())); 316 EXPECT_FALSE(entry->Contains(os_type[i], "10.6", gpu_info()));
317 EXPECT_TRUE(entry->Contains( 317 EXPECT_TRUE(entry->Contains(
318 GpuControlList::kOsChromeOS, "10.6", gpu_info())); 318 GpuControlList::kOsChromeOS, "10.6", gpu_info()));
319 } 319 }
320 320
321 TEST_F(GpuControlListEntryTest, MalformedVendor) { 321 TEST_F(GpuControlListEntryTest, MalformedVendor) {
322 const std::string json = LONG_STRING_CONST( 322 const std::string json = LONG_STRING_CONST(
323 { 323 {
324 "id": 1, 324 "id": 1,
325 "vendor_id": "[0x10de]", 325 "vendor_id": "[0x10de]",
326 "features": [ 326 "features": [
327 "test_feature_0" 327 "test_feature_0"
328 ] 328 ]
329 } 329 }
330 ); 330 );
331 ScopedEntry entry(GetEntryFromString(json)); 331 ScopedEntry entry(GetEntryFromString(json));
332 EXPECT_TRUE(entry == NULL); 332 EXPECT_TRUE(entry.get() == NULL);
333 } 333 }
334 334
335 TEST_F(GpuControlListEntryTest, UnknownFieldEntry) { 335 TEST_F(GpuControlListEntryTest, UnknownFieldEntry) {
336 const std::string json = LONG_STRING_CONST( 336 const std::string json = LONG_STRING_CONST(
337 { 337 {
338 "id": 1, 338 "id": 1,
339 "unknown_field": 0, 339 "unknown_field": 0,
340 "features": [ 340 "features": [
341 "test_feature_0" 341 "test_feature_0"
342 ] 342 ]
343 } 343 }
344 ); 344 );
345 ScopedEntry entry(GetEntryFromString(json)); 345 ScopedEntry entry(GetEntryFromString(json));
346 EXPECT_TRUE(entry != NULL); 346 EXPECT_TRUE(entry.get() != NULL);
347 EXPECT_TRUE(entry->contains_unknown_fields()); 347 EXPECT_TRUE(entry->contains_unknown_fields());
348 EXPECT_FALSE(entry->contains_unknown_features()); 348 EXPECT_FALSE(entry->contains_unknown_features());
349 } 349 }
350 350
351 TEST_F(GpuControlListEntryTest, UnknownExceptionFieldEntry) { 351 TEST_F(GpuControlListEntryTest, UnknownExceptionFieldEntry) {
352 const std::string json = LONG_STRING_CONST( 352 const std::string json = LONG_STRING_CONST(
353 { 353 {
354 "id": 2, 354 "id": 2,
355 "exceptions": [ 355 "exceptions": [
356 { 356 {
357 "unknown_field": 0 357 "unknown_field": 0
358 } 358 }
359 ], 359 ],
360 "features": [ 360 "features": [
361 "test_feature_0" 361 "test_feature_0"
362 ] 362 ]
363 } 363 }
364 ); 364 );
365 ScopedEntry entry(GetEntryFromString(json)); 365 ScopedEntry entry(GetEntryFromString(json));
366 EXPECT_TRUE(entry != NULL); 366 EXPECT_TRUE(entry.get() != NULL);
367 EXPECT_TRUE(entry->contains_unknown_fields()); 367 EXPECT_TRUE(entry->contains_unknown_fields());
368 EXPECT_FALSE(entry->contains_unknown_features()); 368 EXPECT_FALSE(entry->contains_unknown_features());
369 } 369 }
370 370
371 TEST_F(GpuControlListEntryTest, UnknownFeatureEntry) { 371 TEST_F(GpuControlListEntryTest, UnknownFeatureEntry) {
372 const std::string json = LONG_STRING_CONST( 372 const std::string json = LONG_STRING_CONST(
373 { 373 {
374 "id": 1, 374 "id": 1,
375 "features": [ 375 "features": [
376 "some_unknown_feature", 376 "some_unknown_feature",
377 "test_feature_0" 377 "test_feature_0"
378 ] 378 ]
379 } 379 }
380 ); 380 );
381 ScopedEntry entry(GetEntryFromString(json)); 381 ScopedEntry entry(GetEntryFromString(json));
382 EXPECT_TRUE(entry != NULL); 382 EXPECT_TRUE(entry.get() != NULL);
383 EXPECT_FALSE(entry->contains_unknown_fields()); 383 EXPECT_FALSE(entry->contains_unknown_fields());
384 EXPECT_TRUE(entry->contains_unknown_features()); 384 EXPECT_TRUE(entry->contains_unknown_features());
385 EXPECT_EQ(1u, entry->features().size()); 385 EXPECT_EQ(1u, entry->features().size());
386 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0)); 386 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0));
387 387
388 const GpuControlList::OsType os_type[] = { 388 const GpuControlList::OsType os_type[] = {
389 GpuControlList::kOsMacosx, 389 GpuControlList::kOsMacosx,
390 GpuControlList::kOsWin, 390 GpuControlList::kOsWin,
391 GpuControlList::kOsLinux, 391 GpuControlList::kOsLinux,
392 GpuControlList::kOsChromeOS, 392 GpuControlList::kOsChromeOS,
(...skipping 10 matching lines...) Expand all
403 "gl_vendor": { 403 "gl_vendor": {
404 "op": "beginwith", 404 "op": "beginwith",
405 "value": "NVIDIA" 405 "value": "NVIDIA"
406 }, 406 },
407 "features": [ 407 "features": [
408 "test_feature_0" 408 "test_feature_0"
409 ] 409 ]
410 } 410 }
411 ); 411 );
412 ScopedEntry entry(GetEntryFromString(json)); 412 ScopedEntry entry(GetEntryFromString(json));
413 EXPECT_TRUE(entry != NULL); 413 EXPECT_TRUE(entry.get() != NULL);
414 414
415 const GpuControlList::OsType os_type[] = { 415 const GpuControlList::OsType os_type[] = {
416 GpuControlList::kOsMacosx, 416 GpuControlList::kOsMacosx,
417 GpuControlList::kOsWin, 417 GpuControlList::kOsWin,
418 GpuControlList::kOsLinux, 418 GpuControlList::kOsLinux,
419 GpuControlList::kOsChromeOS, 419 GpuControlList::kOsChromeOS,
420 GpuControlList::kOsAndroid 420 GpuControlList::kOsAndroid
421 }; 421 };
422 for (size_t i = 0; i < arraysize(os_type); ++i) 422 for (size_t i = 0; i < arraysize(os_type); ++i)
423 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info())); 423 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info()));
424 } 424 }
425 425
426 TEST_F(GpuControlListEntryTest, GlRendererEntry) { 426 TEST_F(GpuControlListEntryTest, GlRendererEntry) {
427 const std::string json = LONG_STRING_CONST( 427 const std::string json = LONG_STRING_CONST(
428 { 428 {
429 "id": 1, 429 "id": 1,
430 "gl_renderer": { 430 "gl_renderer": {
431 "op": "contains", 431 "op": "contains",
432 "value": "GeForce" 432 "value": "GeForce"
433 }, 433 },
434 "features": [ 434 "features": [
435 "test_feature_0" 435 "test_feature_0"
436 ] 436 ]
437 } 437 }
438 ); 438 );
439 ScopedEntry entry(GetEntryFromString(json)); 439 ScopedEntry entry(GetEntryFromString(json));
440 EXPECT_TRUE(entry != NULL); 440 EXPECT_TRUE(entry.get() != NULL);
441 441
442 const GpuControlList::OsType os_type[] = { 442 const GpuControlList::OsType os_type[] = {
443 GpuControlList::kOsMacosx, 443 GpuControlList::kOsMacosx,
444 GpuControlList::kOsWin, 444 GpuControlList::kOsWin,
445 GpuControlList::kOsLinux, 445 GpuControlList::kOsLinux,
446 GpuControlList::kOsChromeOS, 446 GpuControlList::kOsChromeOS,
447 GpuControlList::kOsAndroid 447 GpuControlList::kOsAndroid
448 }; 448 };
449 for (size_t i = 0; i < arraysize(os_type); ++i) 449 for (size_t i = 0; i < arraysize(os_type); ++i)
450 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info())); 450 EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info()));
451 } 451 }
452 452
453 TEST_F(GpuControlListEntryTest, PerfGraphicsEntry) { 453 TEST_F(GpuControlListEntryTest, PerfGraphicsEntry) {
454 const std::string json = LONG_STRING_CONST( 454 const std::string json = LONG_STRING_CONST(
455 { 455 {
456 "id": 1, 456 "id": 1,
457 "perf_graphics": { 457 "perf_graphics": {
458 "op": "<", 458 "op": "<",
459 "value": "6.0" 459 "value": "6.0"
460 }, 460 },
461 "features": [ 461 "features": [
462 "test_feature_0" 462 "test_feature_0"
463 ] 463 ]
464 } 464 }
465 ); 465 );
466 ScopedEntry entry(GetEntryFromString(json)); 466 ScopedEntry entry(GetEntryFromString(json));
467 EXPECT_TRUE(entry != NULL); 467 EXPECT_TRUE(entry.get() != NULL);
468 EXPECT_TRUE(entry->Contains( 468 EXPECT_TRUE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info()));
469 GpuControlList::kOsWin, "10.6", gpu_info()));
470 } 469 }
471 470
472 TEST_F(GpuControlListEntryTest, PerfGamingEntry) { 471 TEST_F(GpuControlListEntryTest, PerfGamingEntry) {
473 const std::string json = LONG_STRING_CONST( 472 const std::string json = LONG_STRING_CONST(
474 { 473 {
475 "id": 1, 474 "id": 1,
476 "perf_graphics": { 475 "perf_graphics": {
477 "op": "<=", 476 "op": "<=",
478 "value": "4.0" 477 "value": "4.0"
479 }, 478 },
480 "features": [ 479 "features": [
481 "test_feature_0" 480 "test_feature_0"
482 ] 481 ]
483 } 482 }
484 ); 483 );
485 ScopedEntry entry(GetEntryFromString(json)); 484 ScopedEntry entry(GetEntryFromString(json));
486 EXPECT_TRUE(entry != NULL); 485 EXPECT_TRUE(entry.get() != NULL);
487 EXPECT_FALSE(entry->Contains( 486 EXPECT_FALSE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info()));
488 GpuControlList::kOsWin, "10.6", gpu_info()));
489 } 487 }
490 488
491 TEST_F(GpuControlListEntryTest, PerfOverallEntry) { 489 TEST_F(GpuControlListEntryTest, PerfOverallEntry) {
492 const std::string json = LONG_STRING_CONST( 490 const std::string json = LONG_STRING_CONST(
493 { 491 {
494 "id": 1, 492 "id": 1,
495 "perf_overall": { 493 "perf_overall": {
496 "op": "between", 494 "op": "between",
497 "value": "1.0", 495 "value": "1.0",
498 "value2": "9.0" 496 "value2": "9.0"
499 }, 497 },
500 "features": [ 498 "features": [
501 "test_feature_0" 499 "test_feature_0"
502 ] 500 ]
503 } 501 }
504 ); 502 );
505 ScopedEntry entry(GetEntryFromString(json)); 503 ScopedEntry entry(GetEntryFromString(json));
506 EXPECT_TRUE(entry != NULL); 504 EXPECT_TRUE(entry.get() != NULL);
507 EXPECT_TRUE(entry->Contains( 505 EXPECT_TRUE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info()));
508 GpuControlList::kOsWin, "10.6", gpu_info()));
509 } 506 }
510 507
511 TEST_F(GpuControlListEntryTest, DisabledEntry) { 508 TEST_F(GpuControlListEntryTest, DisabledEntry) {
512 const std::string json = LONG_STRING_CONST( 509 const std::string json = LONG_STRING_CONST(
513 { 510 {
514 "id": 1, 511 "id": 1,
515 "disabled": true, 512 "disabled": true,
516 "features": [ 513 "features": [
517 "test_feature_0" 514 "test_feature_0"
518 ] 515 ]
519 } 516 }
520 ); 517 );
521 ScopedEntry entry(GetEntryFromString(json)); 518 ScopedEntry entry(GetEntryFromString(json));
522 EXPECT_TRUE(entry != NULL); 519 EXPECT_TRUE(entry.get() != NULL);
523 EXPECT_TRUE(entry->disabled()); 520 EXPECT_TRUE(entry->disabled());
524 } 521 }
525 522
526 TEST_F(GpuControlListEntryTest, OptimusEntry) { 523 TEST_F(GpuControlListEntryTest, OptimusEntry) {
527 const std::string json = LONG_STRING_CONST( 524 const std::string json = LONG_STRING_CONST(
528 { 525 {
529 "id": 1, 526 "id": 1,
530 "os": { 527 "os": {
531 "type": "linux" 528 "type": "linux"
532 }, 529 },
533 "multi_gpu_style": "optimus", 530 "multi_gpu_style": "optimus",
534 "features": [ 531 "features": [
535 "test_feature_0" 532 "test_feature_0"
536 ] 533 ]
537 } 534 }
538 ); 535 );
539 GPUInfo gpu_info; 536 GPUInfo gpu_info;
540 gpu_info.optimus = true; 537 gpu_info.optimus = true;
541 538
542 ScopedEntry entry(GetEntryFromString(json)); 539 ScopedEntry entry(GetEntryFromString(json));
543 EXPECT_TRUE(entry != NULL); 540 EXPECT_TRUE(entry.get() != NULL);
544 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType()); 541 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
545 EXPECT_TRUE(entry->Contains( 542 EXPECT_TRUE(entry->Contains(
546 GpuControlList::kOsLinux, "10.6", gpu_info)); 543 GpuControlList::kOsLinux, "10.6", gpu_info));
547 } 544 }
548 545
549 TEST_F(GpuControlListEntryTest, AMDSwitchableEntry) { 546 TEST_F(GpuControlListEntryTest, AMDSwitchableEntry) {
550 const std::string json = LONG_STRING_CONST( 547 const std::string json = LONG_STRING_CONST(
551 { 548 {
552 "id": 1, 549 "id": 1,
553 "os": { 550 "os": {
554 "type": "macosx" 551 "type": "macosx"
555 }, 552 },
556 "multi_gpu_style": "amd_switchable", 553 "multi_gpu_style": "amd_switchable",
557 "features": [ 554 "features": [
558 "test_feature_0" 555 "test_feature_0"
559 ] 556 ]
560 } 557 }
561 ); 558 );
562 GPUInfo gpu_info; 559 GPUInfo gpu_info;
563 gpu_info.amd_switchable = true; 560 gpu_info.amd_switchable = true;
564 561
565 ScopedEntry entry(GetEntryFromString(json)); 562 ScopedEntry entry(GetEntryFromString(json));
566 EXPECT_TRUE(entry != NULL); 563 EXPECT_TRUE(entry.get() != NULL);
567 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType()); 564 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
568 EXPECT_TRUE(entry->Contains( 565 EXPECT_TRUE(entry->Contains(
569 GpuControlList::kOsMacosx, "10.6", gpu_info)); 566 GpuControlList::kOsMacosx, "10.6", gpu_info));
570 } 567 }
571 568
572 TEST_F(GpuControlListEntryTest, LexicalDriverVersionEntry) { 569 TEST_F(GpuControlListEntryTest, LexicalDriverVersionEntry) {
573 const std::string json = LONG_STRING_CONST( 570 const std::string json = LONG_STRING_CONST(
574 { 571 {
575 "id": 1, 572 "id": 1,
576 "os": { 573 "os": {
577 "type": "linux" 574 "type": "linux"
578 }, 575 },
579 "vendor_id": "0x1002", 576 "vendor_id": "0x1002",
580 "driver_version": { 577 "driver_version": {
581 "op": "=", 578 "op": "=",
582 "style": "lexical", 579 "style": "lexical",
583 "number": "8.76" 580 "number": "8.76"
584 }, 581 },
585 "features": [ 582 "features": [
586 "test_feature_0" 583 "test_feature_0"
587 ] 584 ]
588 } 585 }
589 ); 586 );
590 GPUInfo gpu_info; 587 GPUInfo gpu_info;
591 gpu_info.gpu.vendor_id = 0x1002; 588 gpu_info.gpu.vendor_id = 0x1002;
592 589
593 ScopedEntry entry(GetEntryFromString(json)); 590 ScopedEntry entry(GetEntryFromString(json));
594 EXPECT_TRUE(entry != NULL); 591 EXPECT_TRUE(entry.get() != NULL);
595 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType()); 592 EXPECT_EQ(GpuControlList::kOsLinux, entry->GetOsType());
596 593
597 gpu_info.driver_version = "8.76"; 594 gpu_info.driver_version = "8.76";
598 EXPECT_TRUE(entry->Contains( 595 EXPECT_TRUE(entry->Contains(
599 GpuControlList::kOsLinux, "10.6", gpu_info)); 596 GpuControlList::kOsLinux, "10.6", gpu_info));
600 597
601 gpu_info.driver_version = "8.768"; 598 gpu_info.driver_version = "8.768";
602 EXPECT_TRUE(entry->Contains( 599 EXPECT_TRUE(entry->Contains(
603 GpuControlList::kOsLinux, "10.6", gpu_info)); 600 GpuControlList::kOsLinux, "10.6", gpu_info));
604 601
(...skipping 11 matching lines...) Expand all
616 }, 613 },
617 "vendor_id": "0x8086", 614 "vendor_id": "0x8086",
618 "device_id": ["0x0166"], 615 "device_id": ["0x0166"],
619 "multi_gpu_category": "any", 616 "multi_gpu_category": "any",
620 "features": [ 617 "features": [
621 "test_feature_0" 618 "test_feature_0"
622 ] 619 ]
623 } 620 }
624 ); 621 );
625 ScopedEntry entry(GetEntryFromString(json)); 622 ScopedEntry entry(GetEntryFromString(json));
626 EXPECT_TRUE(entry != NULL); 623 EXPECT_TRUE(entry.get() != NULL);
627 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType()); 624 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
628 625
629 GPUInfo gpu_info; 626 GPUInfo gpu_info;
630 gpu_info.gpu.vendor_id = 0x10de; 627 gpu_info.gpu.vendor_id = 0x10de;
631 gpu_info.gpu.device_id = 0x1976; 628 gpu_info.gpu.device_id = 0x1976;
632 EXPECT_FALSE(entry->Contains( 629 EXPECT_FALSE(entry->Contains(
633 GpuControlList::kOsMacosx, "10.6", gpu_info)); 630 GpuControlList::kOsMacosx, "10.6", gpu_info));
634 631
635 GPUInfo::GPUDevice gpu_device; 632 GPUInfo::GPUDevice gpu_device;
636 gpu_device.vendor_id = 0x8086; 633 gpu_device.vendor_id = 0x8086;
(...skipping 12 matching lines...) Expand all
649 }, 646 },
650 "vendor_id": "0x8086", 647 "vendor_id": "0x8086",
651 "device_id": ["0x0166"], 648 "device_id": ["0x0166"],
652 "multi_gpu_category": "secondary", 649 "multi_gpu_category": "secondary",
653 "features": [ 650 "features": [
654 "test_feature_0" 651 "test_feature_0"
655 ] 652 ]
656 } 653 }
657 ); 654 );
658 ScopedEntry entry(GetEntryFromString(json)); 655 ScopedEntry entry(GetEntryFromString(json));
659 EXPECT_TRUE(entry != NULL); 656 EXPECT_TRUE(entry.get() != NULL);
660 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType()); 657 EXPECT_EQ(GpuControlList::kOsMacosx, entry->GetOsType());
661 658
662 GPUInfo gpu_info; 659 GPUInfo gpu_info;
663 gpu_info.gpu.vendor_id = 0x10de; 660 gpu_info.gpu.vendor_id = 0x10de;
664 gpu_info.gpu.device_id = 0x1976; 661 gpu_info.gpu.device_id = 0x1976;
665 EXPECT_FALSE(entry->Contains( 662 EXPECT_FALSE(entry->Contains(
666 GpuControlList::kOsMacosx, "10.6", gpu_info)); 663 GpuControlList::kOsMacosx, "10.6", gpu_info));
667 664
668 GPUInfo::GPUDevice gpu_device; 665 GPUInfo::GPUDevice gpu_device;
669 gpu_device.vendor_id = 0x8086; 666 gpu_device.vendor_id = 0x8086;
(...skipping 11 matching lines...) Expand all
681 "driver_version": { 678 "driver_version": {
682 "op": "<", 679 "op": "<",
683 "number": "10.7" 680 "number": "10.7"
684 }, 681 },
685 "features": [ 682 "features": [
686 "test_feature_1" 683 "test_feature_1"
687 ] 684 ]
688 } 685 }
689 ); 686 );
690 ScopedEntry entry(GetEntryFromString(json)); 687 ScopedEntry entry(GetEntryFromString(json));
691 EXPECT_TRUE(entry != NULL); 688 EXPECT_TRUE(entry.get() != NULL);
692 689
693 GPUInfo gpu_info; 690 GPUInfo gpu_info;
694 gpu_info.gpu.vendor_id = 0x8086; 691 gpu_info.gpu.vendor_id = 0x8086;
695 EXPECT_TRUE(entry->NeedsMoreInfo(gpu_info)); 692 EXPECT_TRUE(entry->NeedsMoreInfo(gpu_info));
696 693
697 gpu_info.driver_version = "10.6"; 694 gpu_info.driver_version = "10.6";
698 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info)); 695 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info));
699 } 696 }
700 697
701 TEST_F(GpuControlListEntryTest, NeedsMoreInfoForExceptionsEntry) { 698 TEST_F(GpuControlListEntryTest, NeedsMoreInfoForExceptionsEntry) {
702 const std::string json = LONG_STRING_CONST( 699 const std::string json = LONG_STRING_CONST(
703 { 700 {
704 "id": 1, 701 "id": 1,
705 "vendor_id": "0x8086", 702 "vendor_id": "0x8086",
706 "exceptions": [ 703 "exceptions": [
707 { 704 {
708 "gl_renderer": { 705 "gl_renderer": {
709 "op": "contains", 706 "op": "contains",
710 "value": "mesa" 707 "value": "mesa"
711 } 708 }
712 } 709 }
713 ], 710 ],
714 "features": [ 711 "features": [
715 "test_feature_1" 712 "test_feature_1"
716 ] 713 ]
717 } 714 }
718 ); 715 );
719 ScopedEntry entry(GetEntryFromString(json)); 716 ScopedEntry entry(GetEntryFromString(json));
720 EXPECT_TRUE(entry != NULL); 717 EXPECT_TRUE(entry.get() != NULL);
721 718
722 GPUInfo gpu_info; 719 GPUInfo gpu_info;
723 gpu_info.gpu.vendor_id = 0x8086; 720 gpu_info.gpu.vendor_id = 0x8086;
724 EXPECT_TRUE(entry->NeedsMoreInfo(gpu_info)); 721 EXPECT_TRUE(entry->NeedsMoreInfo(gpu_info));
725 722
726 gpu_info.gl_renderer = "mesa"; 723 gpu_info.gl_renderer = "mesa";
727 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info)); 724 EXPECT_FALSE(entry->NeedsMoreInfo(gpu_info));
728 } 725 }
729 726
730 TEST_F(GpuControlListEntryTest, FeatureTypeAllEntry) { 727 TEST_F(GpuControlListEntryTest, FeatureTypeAllEntry) {
731 const std::string json = LONG_STRING_CONST( 728 const std::string json = LONG_STRING_CONST(
732 { 729 {
733 "id": 1, 730 "id": 1,
734 "features": [ 731 "features": [
735 "all" 732 "all"
736 ] 733 ]
737 } 734 }
738 ); 735 );
739 ScopedEntry entry(GetEntryFromString(json, true)); 736 ScopedEntry entry(GetEntryFromString(json, true));
740 EXPECT_TRUE(entry != NULL); 737 EXPECT_TRUE(entry.get() != NULL);
741 EXPECT_EQ(3u, entry->features().size()); 738 EXPECT_EQ(3u, entry->features().size());
742 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0)); 739 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0));
743 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_1)); 740 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_1));
744 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_2)); 741 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_2));
745 } 742 }
746 743
747 } // namespace gpu 744 } // namespace gpu
748 745
OLDNEW
« no previous file with comments | « gpu/config/gpu_control_list.cc ('k') | gpu/config/gpu_info_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698