Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "gpu/config/gpu_util.h" | 5 #include "gpu/config/gpu_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "gpu/config/gpu_control_list_jsons.h" | 11 #include "gpu/config/gpu_control_list_jsons.h" |
| 12 #include "gpu/config/gpu_driver_bug_list.h" | 12 #include "gpu/config/gpu_driver_bug_list.h" |
| 13 #include "gpu/config/gpu_info.h" | 13 #include "gpu/config/gpu_info.h" |
| 14 #include "gpu/config/gpu_info_collector.h" | 14 #include "gpu/config/gpu_info_collector.h" |
| 15 #include "gpu/config/gpu_switches.h" | 15 #include "gpu/config/gpu_switches.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/gl/gl_switches.h" | 17 #include "ui/gl/gl_switches.h" |
| 18 | 18 |
| 19 namespace gpu { | 19 namespace gpu { |
| 20 | 20 |
| 21 TEST(GpuUtilTest, MergeFeatureSets) { | |
| 22 { | |
| 23 // Merge two empty sets. | |
| 24 std::set<int> src; | |
| 25 std::set<int> dst; | |
| 26 EXPECT_TRUE(dst.empty()); | |
| 27 MergeFeatureSets(&dst, src); | |
| 28 EXPECT_TRUE(dst.empty()); | |
| 29 } | |
| 30 { | |
| 31 // Merge an empty set into a set with elements. | |
| 32 std::set<int> src; | |
| 33 std::set<int> dst; | |
| 34 dst.insert(1); | |
| 35 EXPECT_EQ(1u, dst.size()); | |
| 36 MergeFeatureSets(&dst, src); | |
| 37 EXPECT_EQ(1u, dst.size()); | |
| 38 } | |
| 39 { | |
| 40 // Merge two sets where the source elements are already in the target set. | |
| 41 std::set<int> src; | |
| 42 std::set<int> dst; | |
| 43 src.insert(1); | |
| 44 dst.insert(1); | |
| 45 EXPECT_EQ(1u, dst.size()); | |
| 46 MergeFeatureSets(&dst, src); | |
| 47 EXPECT_EQ(1u, dst.size()); | |
| 48 } | |
| 49 { | |
| 50 // Merge two sets with different elements. | |
| 51 std::set<int> src; | |
| 52 std::set<int> dst; | |
| 53 src.insert(1); | |
| 54 dst.insert(2); | |
| 55 EXPECT_EQ(1u, dst.size()); | |
| 56 MergeFeatureSets(&dst, src); | |
| 57 EXPECT_EQ(2u, dst.size()); | |
| 58 } | |
| 59 } | |
|
Ken Russell (switch to Gerrit)
2016/11/15 01:25:15
Does your new test provide all the coverage you fe
Zhenyao Mo
2016/11/15 01:38:21
The MergeFeatrure function is removed so there is
| |
| 60 | |
| 61 TEST(GpuUtilTest, StringToFeatureSet) { | 21 TEST(GpuUtilTest, StringToFeatureSet) { |
| 62 { | 22 { |
| 63 // zero feature. | 23 // zero feature. |
| 64 std::set<int> features; | 24 std::set<int> features; |
| 65 StringToFeatureSet("", &features); | 25 StringToFeatureSet("", &features); |
| 66 EXPECT_EQ(0u, features.size()); | 26 EXPECT_EQ(0u, features.size()); |
| 67 } | 27 } |
| 68 { | 28 { |
| 69 // One features. | 29 // One features. |
| 70 std::set<int> features; | 30 std::set<int> features; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 EXPECT_EQ(gpu_info.secondary_gpus.size(), 2ul); | 163 EXPECT_EQ(gpu_info.secondary_gpus.size(), 2ul); |
| 204 | 164 |
| 205 command_line.AppendSwitchASCII(switches::kGpuTestingSecondaryVendorIDs, ""); | 165 command_line.AppendSwitchASCII(switches::kGpuTestingSecondaryVendorIDs, ""); |
| 206 command_line.AppendSwitchASCII(switches::kGpuTestingSecondaryDeviceIDs, ""); | 166 command_line.AppendSwitchASCII(switches::kGpuTestingSecondaryDeviceIDs, ""); |
| 207 | 167 |
| 208 ParseSecondaryGpuDevicesFromCommandLine(command_line, &gpu_info); | 168 ParseSecondaryGpuDevicesFromCommandLine(command_line, &gpu_info); |
| 209 EXPECT_EQ(gpu_info.secondary_gpus.size(), 0ul); | 169 EXPECT_EQ(gpu_info.secondary_gpus.size(), 0ul); |
| 210 } | 170 } |
| 211 | 171 |
| 212 } // namespace gpu | 172 } // namespace gpu |
| OLD | NEW |