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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "gpu/config/gpu_control_list.h" | 8 #include "gpu/config/gpu_control_list.h" |
9 #include "gpu/config/gpu_info.h" | 9 #include "gpu/config/gpu_info.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 std::set<int> features = control_list->MakeDecision( | 282 std::set<int> features = control_list->MakeDecision( |
283 GpuControlList::kOsWin, kOsVersion, gpu_info()); | 283 GpuControlList::kOsWin, kOsVersion, gpu_info()); |
284 EXPECT_EMPTY_SET(features); | 284 EXPECT_EMPTY_SET(features); |
285 std::vector<uint32> flag_entries; | 285 std::vector<uint32> flag_entries; |
286 control_list->GetDecisionEntries(&flag_entries, false); | 286 control_list->GetDecisionEntries(&flag_entries, false); |
287 EXPECT_EQ(0u, flag_entries.size()); | 287 EXPECT_EQ(0u, flag_entries.size()); |
288 control_list->GetDecisionEntries(&flag_entries, true); | 288 control_list->GetDecisionEntries(&flag_entries, true); |
289 EXPECT_EQ(1u, flag_entries.size()); | 289 EXPECT_EQ(1u, flag_entries.size()); |
290 } | 290 } |
291 | 291 |
| 292 TEST_F(GpuControlListTest, NeedsMoreInfo) { |
| 293 const std::string json = LONG_STRING_CONST( |
| 294 { |
| 295 "name": "gpu control list", |
| 296 "version": "0.1", |
| 297 "entries": [ |
| 298 { |
| 299 "id": 1, |
| 300 "os": { |
| 301 "type": "win" |
| 302 }, |
| 303 "vendor_id": "0x10de", |
| 304 "driver_version": { |
| 305 "op": "<", |
| 306 "value": "12" |
| 307 }, |
| 308 "features": [ |
| 309 "test_feature_0" |
| 310 ] |
| 311 } |
| 312 ] |
| 313 } |
| 314 ); |
| 315 GPUInfo gpu_info; |
| 316 gpu_info.gpu.vendor_id = kNvidiaVendorId; |
| 317 |
| 318 scoped_ptr<GpuControlList> control_list(Create()); |
| 319 EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs)); |
| 320 |
| 321 std::set<int> features = control_list->MakeDecision( |
| 322 GpuControlList::kOsWin, kOsVersion, gpu_info); |
| 323 EXPECT_EMPTY_SET(features); |
| 324 EXPECT_TRUE(control_list->needs_more_info()); |
| 325 std::vector<uint32> decision_entries; |
| 326 control_list->GetDecisionEntries(&decision_entries, false); |
| 327 EXPECT_EQ(0u, decision_entries.size()); |
| 328 |
| 329 gpu_info.driver_version = "11"; |
| 330 features = control_list->MakeDecision( |
| 331 GpuControlList::kOsWin, kOsVersion, gpu_info); |
| 332 EXPECT_SINGLE_FEATURE(features, TEST_FEATURE_0); |
| 333 EXPECT_FALSE(control_list->needs_more_info()); |
| 334 control_list->GetDecisionEntries(&decision_entries, false); |
| 335 EXPECT_EQ(1u, decision_entries.size()); |
| 336 } |
| 337 |
292 TEST_F(GpuControlListTest, NeedsMoreInfoForExceptions) { | 338 TEST_F(GpuControlListTest, NeedsMoreInfoForExceptions) { |
293 const std::string json = LONG_STRING_CONST( | 339 const std::string json = LONG_STRING_CONST( |
294 { | 340 { |
295 "name": "gpu control list", | 341 "name": "gpu control list", |
296 "version": "0.1", | 342 "version": "0.1", |
297 "entries": [ | 343 "entries": [ |
298 { | 344 { |
299 "id": 1, | 345 "id": 1, |
300 "os": { | 346 "os": { |
301 "type": "linux" | 347 "type": "linux" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 // For non AMD switchable | 580 // For non AMD switchable |
535 gpu_info.amd_switchable = false; | 581 gpu_info.amd_switchable = false; |
536 features = control_list->MakeDecision( | 582 features = control_list->MakeDecision( |
537 GpuControlList::kOsWin, kOsVersion, gpu_info); | 583 GpuControlList::kOsWin, kOsVersion, gpu_info); |
538 EXPECT_EMPTY_SET(features); | 584 EXPECT_EMPTY_SET(features); |
539 } | 585 } |
540 } | 586 } |
541 | 587 |
542 } // namespace gpu | 588 } // namespace gpu |
543 | 589 |
OLD | NEW |