| 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 "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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 void SetUp() override { | 52 void SetUp() override { |
| 53 gpu_info_.gpu.vendor_id = 0x10de; | 53 gpu_info_.gpu.vendor_id = 0x10de; |
| 54 gpu_info_.gpu.device_id = 0x0640; | 54 gpu_info_.gpu.device_id = 0x0640; |
| 55 gpu_info_.gpu.active = true; | 55 gpu_info_.gpu.active = true; |
| 56 gpu_info_.driver_vendor = "NVIDIA"; | 56 gpu_info_.driver_vendor = "NVIDIA"; |
| 57 gpu_info_.driver_version = "1.6.18"; | 57 gpu_info_.driver_version = "1.6.18"; |
| 58 gpu_info_.driver_date = "7-14-2009"; | 58 gpu_info_.driver_date = "7-14-2009"; |
| 59 gpu_info_.gl_version = "2.1 NVIDIA-8.24.11 310.90.9b01"; | 59 gpu_info_.gl_version = "2.1 NVIDIA-8.24.11 310.90.9b01"; |
| 60 gpu_info_.gl_vendor = "NVIDIA Corporation"; | 60 gpu_info_.gl_vendor = "NVIDIA Corporation"; |
| 61 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; | 61 gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; |
| 62 gpu_info_.performance_stats.graphics = 5.0; | |
| 63 gpu_info_.performance_stats.gaming = 5.0; | |
| 64 gpu_info_.performance_stats.overall = 5.0; | |
| 65 } | 62 } |
| 66 | 63 |
| 67 protected: | 64 protected: |
| 68 GPUInfo gpu_info_; | 65 GPUInfo gpu_info_; |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 TEST_F(GpuControlListEntryTest, DetailedEntry) { | 68 TEST_F(GpuControlListEntryTest, DetailedEntry) { |
| 72 const std::string json = LONG_STRING_CONST( | 69 const std::string json = LONG_STRING_CONST( |
| 73 { | 70 { |
| 74 "id": 5, | 71 "id": 5, |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 EXPECT_TRUE(entry->Contains( | 600 EXPECT_TRUE(entry->Contains( |
| 604 GpuControlList::kOsMacosx, "10.9", gpu_info)); | 601 GpuControlList::kOsMacosx, "10.9", gpu_info)); |
| 605 | 602 |
| 606 gpu_info.gl_extensions = "GL_SGIS_generate_mipmap " | 603 gpu_info.gl_extensions = "GL_SGIS_generate_mipmap " |
| 607 "GL_SUN_slice_accum " | 604 "GL_SUN_slice_accum " |
| 608 "GL_SGIX_shadow"; | 605 "GL_SGIX_shadow"; |
| 609 EXPECT_FALSE(entry->Contains( | 606 EXPECT_FALSE(entry->Contains( |
| 610 GpuControlList::kOsMacosx, "10.9", gpu_info)); | 607 GpuControlList::kOsMacosx, "10.9", gpu_info)); |
| 611 } | 608 } |
| 612 | 609 |
| 613 TEST_F(GpuControlListEntryTest, PerfGraphicsEntry) { | |
| 614 const std::string json = LONG_STRING_CONST( | |
| 615 { | |
| 616 "id": 1, | |
| 617 "perf_graphics": { | |
| 618 "op": "<", | |
| 619 "value": "6.0" | |
| 620 }, | |
| 621 "features": [ | |
| 622 "test_feature_0" | |
| 623 ] | |
| 624 } | |
| 625 ); | |
| 626 ScopedEntry entry(GetEntryFromString(json)); | |
| 627 EXPECT_TRUE(entry.get() != NULL); | |
| 628 EXPECT_TRUE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info())); | |
| 629 } | |
| 630 | |
| 631 TEST_F(GpuControlListEntryTest, PerfGamingEntry) { | |
| 632 const std::string json = LONG_STRING_CONST( | |
| 633 { | |
| 634 "id": 1, | |
| 635 "perf_graphics": { | |
| 636 "op": "<=", | |
| 637 "value": "4.0" | |
| 638 }, | |
| 639 "features": [ | |
| 640 "test_feature_0" | |
| 641 ] | |
| 642 } | |
| 643 ); | |
| 644 ScopedEntry entry(GetEntryFromString(json)); | |
| 645 EXPECT_TRUE(entry.get() != NULL); | |
| 646 EXPECT_FALSE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info())); | |
| 647 } | |
| 648 | |
| 649 TEST_F(GpuControlListEntryTest, PerfOverallEntry) { | |
| 650 const std::string json = LONG_STRING_CONST( | |
| 651 { | |
| 652 "id": 1, | |
| 653 "perf_overall": { | |
| 654 "op": "between", | |
| 655 "value": "1.0", | |
| 656 "value2": "9.0" | |
| 657 }, | |
| 658 "features": [ | |
| 659 "test_feature_0" | |
| 660 ] | |
| 661 } | |
| 662 ); | |
| 663 ScopedEntry entry(GetEntryFromString(json)); | |
| 664 EXPECT_TRUE(entry.get() != NULL); | |
| 665 EXPECT_TRUE(entry->Contains(GpuControlList::kOsWin, "10.6", gpu_info())); | |
| 666 } | |
| 667 | |
| 668 TEST_F(GpuControlListEntryTest, DisabledEntry) { | 610 TEST_F(GpuControlListEntryTest, DisabledEntry) { |
| 669 const std::string json = LONG_STRING_CONST( | 611 const std::string json = LONG_STRING_CONST( |
| 670 { | 612 { |
| 671 "id": 1, | 613 "id": 1, |
| 672 "disabled": true, | 614 "disabled": true, |
| 673 "features": [ | 615 "features": [ |
| 674 "test_feature_0" | 616 "test_feature_0" |
| 675 ] | 617 ] |
| 676 } | 618 } |
| 677 ); | 619 ); |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 ); | 1227 ); |
| 1286 // By default, secondary GPU is active. | 1228 // By default, secondary GPU is active. |
| 1287 EntryShouldNotApply(json); | 1229 EntryShouldNotApply(json); |
| 1288 | 1230 |
| 1289 ActivatePrimaryGPU(); | 1231 ActivatePrimaryGPU(); |
| 1290 EntryShouldApply(json); | 1232 EntryShouldApply(json); |
| 1291 } | 1233 } |
| 1292 | 1234 |
| 1293 } // namespace gpu | 1235 } // namespace gpu |
| 1294 | 1236 |
| OLD | NEW |