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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "gpu/config/gpu_control_list.h" | 10 #include "gpu/config/gpu_control_list.h" |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 809 } |
810 ); | 810 ); |
811 ScopedEntry entry(GetEntryFromString(json, true)); | 811 ScopedEntry entry(GetEntryFromString(json, true)); |
812 EXPECT_TRUE(entry.get() != NULL); | 812 EXPECT_TRUE(entry.get() != NULL); |
813 EXPECT_EQ(3u, entry->features().size()); | 813 EXPECT_EQ(3u, entry->features().size()); |
814 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0)); | 814 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_0)); |
815 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_1)); | 815 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_1)); |
816 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_2)); | 816 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_2)); |
817 } | 817 } |
818 | 818 |
| 819 TEST_F(GpuControlListEntryTest, FeatureTypeAllEntryWithExceptions) { |
| 820 const std::string json = LONG_STRING_CONST( |
| 821 { |
| 822 "id": 1, |
| 823 "features": [ |
| 824 "all", |
| 825 {"exceptions" : [ |
| 826 "test_feature_0" |
| 827 ]} |
| 828 ] |
| 829 } |
| 830 ); |
| 831 bool supports_feature_type_all = true; |
| 832 ScopedEntry entry(GetEntryFromString(json, supports_feature_type_all)); |
| 833 EXPECT_TRUE(entry.get() != NULL); |
| 834 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_1)); |
| 835 EXPECT_EQ(1u, entry->features().count(TEST_FEATURE_2)); |
| 836 EXPECT_EQ(2u, entry->features().size()); |
| 837 |
| 838 supports_feature_type_all = false; |
| 839 entry = ScopedEntry(GetEntryFromString(json, supports_feature_type_all)); |
| 840 EXPECT_TRUE(entry.get() == NULL); |
| 841 } |
| 842 |
| 843 TEST_F(GpuControlListEntryTest, FeatureTypeAllEntryWithUnknownField) { |
| 844 const std::string json = LONG_STRING_CONST( |
| 845 { |
| 846 "id": 1, |
| 847 "features": [ |
| 848 "all", { |
| 849 "exceptions" : [ |
| 850 "test_feature_0" |
| 851 ], |
| 852 "unknown_field" : 0 |
| 853 } |
| 854 ] |
| 855 } |
| 856 ); |
| 857 bool supports_feature_type_all = true; |
| 858 ScopedEntry entry(GetEntryFromString(json, supports_feature_type_all)); |
| 859 EXPECT_TRUE(entry.get() == NULL); |
| 860 |
| 861 supports_feature_type_all = false; |
| 862 entry = ScopedEntry(GetEntryFromString(json, supports_feature_type_all)); |
| 863 EXPECT_TRUE(entry.get() == NULL); |
| 864 } |
| 865 |
819 TEST_F(GpuControlListEntryTest, InvalidVendorIdEntry) { | 866 TEST_F(GpuControlListEntryTest, InvalidVendorIdEntry) { |
820 const std::string json = LONG_STRING_CONST( | 867 const std::string json = LONG_STRING_CONST( |
821 { | 868 { |
822 "id": 1, | 869 "id": 1, |
823 "vendor_id": "0x0000", | 870 "vendor_id": "0x0000", |
824 "features": [ | 871 "features": [ |
825 "test_feature_1" | 872 "test_feature_1" |
826 ] | 873 ] |
827 } | 874 } |
828 ); | 875 ); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 EXPECT_TRUE(entry->Contains(GpuControlList::kOsLinux, | 1316 EXPECT_TRUE(entry->Contains(GpuControlList::kOsLinux, |
1270 "3.13.0-63-generic", | 1317 "3.13.0-63-generic", |
1271 gpu_info)); | 1318 gpu_info)); |
1272 EXPECT_FALSE(entry->Contains(GpuControlList::kOsLinux, | 1319 EXPECT_FALSE(entry->Contains(GpuControlList::kOsLinux, |
1273 "3.19.2-1-generic", | 1320 "3.19.2-1-generic", |
1274 gpu_info)); | 1321 gpu_info)); |
1275 } | 1322 } |
1276 | 1323 |
1277 } // namespace gpu | 1324 } // namespace gpu |
1278 | 1325 |
OLD | NEW |