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__ |
11 | 11 |
12 namespace gpu { | 12 namespace gpu { |
13 | 13 |
14 enum TestFeatureType { | 14 enum TestFeatureType { |
15 TEST_FEATURE_0 = 0, | 15 TEST_FEATURE_0 = 0, |
16 TEST_FEATURE_1, | 16 TEST_FEATURE_1, |
17 TEST_FEATURE_2 | 17 TEST_FEATURE_2 |
18 }; | 18 }; |
19 | 19 |
20 class GpuControlListEntryTest : public testing::Test { | 20 class GpuControlListEntryTest : public testing::Test { |
21 public: | 21 public: |
22 GpuControlListEntryTest() { } | 22 GpuControlListEntryTest() { } |
23 virtual ~GpuControlListEntryTest() { } | 23 ~GpuControlListEntryTest() override {} |
24 | 24 |
25 const GPUInfo& gpu_info() const { | 25 const GPUInfo& gpu_info() const { |
26 return gpu_info_; | 26 return gpu_info_; |
27 } | 27 } |
28 | 28 |
29 typedef GpuControlList::ScopedGpuControlListEntry ScopedEntry; | 29 typedef GpuControlList::ScopedGpuControlListEntry ScopedEntry; |
30 | 30 |
31 static ScopedEntry GetEntryFromString( | 31 static ScopedEntry GetEntryFromString( |
32 const std::string& json, bool supports_feature_type_all) { | 32 const std::string& json, bool supports_feature_type_all) { |
33 scoped_ptr<base::Value> root; | 33 scoped_ptr<base::Value> root; |
34 root.reset(base::JSONReader::Read(json)); | 34 root.reset(base::JSONReader::Read(json)); |
35 base::DictionaryValue* value = NULL; | 35 base::DictionaryValue* value = NULL; |
36 if (root.get() == NULL || !root->GetAsDictionary(&value)) | 36 if (root.get() == NULL || !root->GetAsDictionary(&value)) |
37 return NULL; | 37 return NULL; |
38 | 38 |
39 GpuControlList::FeatureMap feature_map; | 39 GpuControlList::FeatureMap feature_map; |
40 feature_map["test_feature_0"] = TEST_FEATURE_0; | 40 feature_map["test_feature_0"] = TEST_FEATURE_0; |
41 feature_map["test_feature_1"] = TEST_FEATURE_1; | 41 feature_map["test_feature_1"] = TEST_FEATURE_1; |
42 feature_map["test_feature_2"] = TEST_FEATURE_2; | 42 feature_map["test_feature_2"] = TEST_FEATURE_2; |
43 | 43 |
44 return GpuControlList::GpuControlListEntry::GetEntryFromValue( | 44 return GpuControlList::GpuControlListEntry::GetEntryFromValue( |
45 value, true, feature_map, supports_feature_type_all); | 45 value, true, feature_map, supports_feature_type_all); |
46 } | 46 } |
47 | 47 |
48 static ScopedEntry GetEntryFromString(const std::string& json) { | 48 static ScopedEntry GetEntryFromString(const std::string& json) { |
49 return GetEntryFromString(json, false); | 49 return GetEntryFromString(json, false); |
50 } | 50 } |
51 | 51 |
52 virtual void SetUp() { | 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; | 62 gpu_info_.performance_stats.graphics = 5.0; |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 GpuControlList::kOsMacosx, "10.6", gpu_info)); | 1073 GpuControlList::kOsMacosx, "10.6", gpu_info)); |
1074 | 1074 |
1075 gpu_info.machine_model_version = ""; | 1075 gpu_info.machine_model_version = ""; |
1076 EXPECT_TRUE(entry->Contains( | 1076 EXPECT_TRUE(entry->Contains( |
1077 GpuControlList::kOsMacosx, "10.6", gpu_info)); | 1077 GpuControlList::kOsMacosx, "10.6", gpu_info)); |
1078 } | 1078 } |
1079 | 1079 |
1080 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest { | 1080 class GpuControlListEntryDualGPUTest : public GpuControlListEntryTest { |
1081 public: | 1081 public: |
1082 GpuControlListEntryDualGPUTest() { } | 1082 GpuControlListEntryDualGPUTest() { } |
1083 virtual ~GpuControlListEntryDualGPUTest() { } | 1083 ~GpuControlListEntryDualGPUTest() override {} |
1084 | 1084 |
1085 virtual void SetUp() override { | 1085 void SetUp() override { |
1086 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as | 1086 // Set up a NVIDIA/Intel dual, with NVIDIA as primary and Intel as |
1087 // secondary, and initially Intel is active. | 1087 // secondary, and initially Intel is active. |
1088 gpu_info_.gpu.vendor_id = 0x10de; | 1088 gpu_info_.gpu.vendor_id = 0x10de; |
1089 gpu_info_.gpu.device_id = 0x0640; | 1089 gpu_info_.gpu.device_id = 0x0640; |
1090 gpu_info_.gpu.active = false; | 1090 gpu_info_.gpu.active = false; |
1091 GPUInfo::GPUDevice second_gpu; | 1091 GPUInfo::GPUDevice second_gpu; |
1092 second_gpu.vendor_id = 0x8086; | 1092 second_gpu.vendor_id = 0x8086; |
1093 second_gpu.device_id = 0x0166; | 1093 second_gpu.device_id = 0x0166; |
1094 second_gpu.active = true; | 1094 second_gpu.active = true; |
1095 gpu_info_.secondary_gpus.push_back(second_gpu); | 1095 gpu_info_.secondary_gpus.push_back(second_gpu); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 ); | 1282 ); |
1283 // By default, secondary GPU is active. | 1283 // By default, secondary GPU is active. |
1284 EntryShouldNotApply(json); | 1284 EntryShouldNotApply(json); |
1285 | 1285 |
1286 ActivatePrimaryGPU(); | 1286 ActivatePrimaryGPU(); |
1287 EntryShouldApply(json); | 1287 EntryShouldApply(json); |
1288 } | 1288 } |
1289 | 1289 |
1290 } // namespace gpu | 1290 } // namespace gpu |
1291 | 1291 |
OLD | NEW |