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/logging.h" | 5 #include "base/logging.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "gpu/config/gpu_control_list_jsons.h" | 7 #include "gpu/config/gpu_control_list_jsons.h" |
8 #include "gpu/config/gpu_driver_bug_list.h" | 8 #include "gpu/config/gpu_driver_bug_list.h" |
9 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 9 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
10 #include "gpu/config/gpu_info.h" | 10 #include "gpu/config/gpu_info.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
| 13 #define LONG_STRING_CONST(...) #__VA_ARGS__ |
| 14 |
13 namespace gpu { | 15 namespace gpu { |
14 | 16 |
15 class GpuDriverBugListTest : public testing::Test { | 17 class GpuDriverBugListTest : public testing::Test { |
16 public: | 18 public: |
17 GpuDriverBugListTest() { } | 19 GpuDriverBugListTest() { } |
18 | 20 |
19 virtual ~GpuDriverBugListTest() { } | 21 virtual ~GpuDriverBugListTest() { } |
20 | 22 |
21 const GPUInfo& gpu_info() const { | 23 const GPUInfo& gpu_info() const { |
22 return gpu_info_; | 24 return gpu_info_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs)); | 69 EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs)); |
68 | 70 |
69 GPUInfo gpu_info; | 71 GPUInfo gpu_info; |
70 gpu_info.gl_vendor = "Imagination Technologies"; | 72 gpu_info.gl_vendor = "Imagination Technologies"; |
71 gpu_info.gl_renderer = "PowerVR SGX 540"; | 73 gpu_info.gl_renderer = "PowerVR SGX 540"; |
72 std::set<int> bugs = list->MakeDecision( | 74 std::set<int> bugs = list->MakeDecision( |
73 GpuControlList::kOsAndroid, "4.1", gpu_info); | 75 GpuControlList::kOsAndroid, "4.1", gpu_info); |
74 EXPECT_EQ(1u, bugs.count(USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS)); | 76 EXPECT_EQ(1u, bugs.count(USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS)); |
75 } | 77 } |
76 | 78 |
| 79 TEST_F(GpuDriverBugListTest, GpuSwitching) { |
| 80 const std::string json = LONG_STRING_CONST( |
| 81 { |
| 82 "name": "gpu driver bug list", |
| 83 "version": "0.1", |
| 84 "entries": [ |
| 85 { |
| 86 "id": 1, |
| 87 "os": { |
| 88 "type": "macosx" |
| 89 }, |
| 90 "features": [ |
| 91 "force_discrete_gpu" |
| 92 ] |
| 93 }, |
| 94 { |
| 95 "id": 2, |
| 96 "os": { |
| 97 "type": "win" |
| 98 }, |
| 99 "features": [ |
| 100 "force_integrated_gpu" |
| 101 ] |
| 102 } |
| 103 ] |
| 104 } |
| 105 ); |
| 106 scoped_ptr<GpuDriverBugList> driver_bug_list(GpuDriverBugList::Create()); |
| 107 EXPECT_TRUE(driver_bug_list->LoadList(json, GpuControlList::kAllOs)); |
| 108 std::set<int> switching = driver_bug_list->MakeDecision( |
| 109 GpuControlList::kOsMacosx, "10.8", gpu_info()); |
| 110 EXPECT_EQ(1u, switching.size()); |
| 111 EXPECT_EQ(1u, switching.count(FORCE_DISCRETE_GPU)); |
| 112 std::vector<uint32> entries; |
| 113 driver_bug_list->GetDecisionEntries(&entries, false); |
| 114 ASSERT_EQ(1u, entries.size()); |
| 115 EXPECT_EQ(1u, entries[0]); |
| 116 |
| 117 driver_bug_list.reset(GpuDriverBugList::Create()); |
| 118 EXPECT_TRUE(driver_bug_list->LoadList(json, GpuControlList::kAllOs)); |
| 119 switching = driver_bug_list->MakeDecision( |
| 120 GpuControlList::kOsWin, "6.1", gpu_info()); |
| 121 EXPECT_EQ(1u, switching.size()); |
| 122 EXPECT_EQ(1u, switching.count(FORCE_INTEGRATED_GPU)); |
| 123 driver_bug_list->GetDecisionEntries(&entries, false); |
| 124 ASSERT_EQ(1u, entries.size()); |
| 125 EXPECT_EQ(2u, entries[0]); |
| 126 } |
| 127 |
77 } // namespace gpu | 128 } // namespace gpu |
78 | 129 |
OLD | NEW |