summaryrefslogtreecommitdiffstats
path: root/chromium/gpu/config/gpu_control_list_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/gpu/config/gpu_control_list_unittest.cc')
-rw-r--r--chromium/gpu/config/gpu_control_list_unittest.cc97
1 files changed, 96 insertions, 1 deletions
diff --git a/chromium/gpu/config/gpu_control_list_unittest.cc b/chromium/gpu/config/gpu_control_list_unittest.cc
index 996276aff61..03a7d0e2491 100644
--- a/chromium/gpu/config/gpu_control_list_unittest.cc
+++ b/chromium/gpu/config/gpu_control_list_unittest.cc
@@ -12,6 +12,7 @@
const char kOsVersion[] = "10.6.4";
const uint32 kIntelVendorId = 0x8086;
const uint32 kNvidiaVendorId = 0x10de;
+const uint32 kAmdVendorId = 0x10de;
#define LONG_STRING_CONST(...) #__VA_ARGS__
@@ -52,7 +53,8 @@ class GpuControlListTest : public testing::Test {
gpu_info_.driver_vendor = "NVIDIA";
gpu_info_.driver_version = "1.6.18";
gpu_info_.driver_date = "7-14-2009";
- gpu_info_.machine_model = "MacBookPro 7.1";
+ gpu_info_.machine_model_name = "MacBookPro";
+ gpu_info_.machine_model_version = "7.1";
gpu_info_.gl_vendor = "NVIDIA Corporation";
gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
gpu_info_.performance_stats.graphics = 5.0;
@@ -447,5 +449,98 @@ TEST_F(GpuControlListTest, ExceptionWithoutVendorId) {
EXPECT_SINGLE_FEATURE(features, TEST_FEATURE_0);
}
+TEST_F(GpuControlListTest, AMDSwitchable) {
+ GPUInfo gpu_info;
+ gpu_info.amd_switchable = true;
+ gpu_info.gpu.vendor_id = kAmdVendorId;
+ gpu_info.gpu.device_id = 0x6760;
+ GPUInfo::GPUDevice integrated_gpu;
+ integrated_gpu.vendor_id = kIntelVendorId;
+ integrated_gpu.device_id = 0x0116;
+ gpu_info.secondary_gpus.push_back(integrated_gpu);
+
+ { // amd_switchable_discrete entry
+ const std::string json= LONG_STRING_CONST(
+ {
+ "name": "gpu control list",
+ "version": "0.1",
+ "entries": [
+ {
+ "id": 1,
+ "os": {
+ "type": "win"
+ },
+ "multi_gpu_style": "amd_switchable_discrete",
+ "features": [
+ "test_feature_0"
+ ]
+ }
+ ]
+ }
+ );
+
+ scoped_ptr<GpuControlList> control_list(Create());
+ EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
+
+ // Integrated GPU is active
+ gpu_info.gpu.active = false;
+ gpu_info.secondary_gpus[0].active = true;
+ std::set<int> features = control_list->MakeDecision(
+ GpuControlList::kOsWin, kOsVersion, gpu_info);
+ EXPECT_EMPTY_SET(features);
+
+ // Discrete GPU is active
+ gpu_info.gpu.active = true;
+ gpu_info.secondary_gpus[0].active = false;
+ features = control_list->MakeDecision(
+ GpuControlList::kOsWin, kOsVersion, gpu_info);
+ EXPECT_SINGLE_FEATURE(features, TEST_FEATURE_0);
+ }
+
+ { // amd_switchable_integrated entry
+ const std::string json= LONG_STRING_CONST(
+ {
+ "name": "gpu control list",
+ "version": "0.1",
+ "entries": [
+ {
+ "id": 1,
+ "os": {
+ "type": "win"
+ },
+ "multi_gpu_style": "amd_switchable_integrated",
+ "features": [
+ "test_feature_0"
+ ]
+ }
+ ]
+ }
+ );
+
+ scoped_ptr<GpuControlList> control_list(Create());
+ EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
+
+ // Discrete GPU is active
+ gpu_info.gpu.active = true;
+ gpu_info.secondary_gpus[0].active = false;
+ std::set<int> features = control_list->MakeDecision(
+ GpuControlList::kOsWin, kOsVersion, gpu_info);
+ EXPECT_EMPTY_SET(features);
+
+ // Integrated GPU is active
+ gpu_info.gpu.active = false;
+ gpu_info.secondary_gpus[0].active = true;
+ features = control_list->MakeDecision(
+ GpuControlList::kOsWin, kOsVersion, gpu_info);
+ EXPECT_SINGLE_FEATURE(features, TEST_FEATURE_0);
+
+ // For non AMD switchable
+ gpu_info.amd_switchable = false;
+ features = control_list->MakeDecision(
+ GpuControlList::kOsWin, kOsVersion, gpu_info);
+ EXPECT_EMPTY_SET(features);
+ }
+}
+
} // namespace gpu