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 3 // found in the LICENSE file. 4 5 #include "gpu/config/gpu_util.h" 6 #include "testing/gtest/include/gtest/gtest.h" 7 #include "ui/gl/gl_switches.h" 8 9 namespace gpu { 10 11 TEST(GpuUtilTest, GpuSwitchingOptionFromString) { 12 // Test StringToGpuSwitchingOption. 13 EXPECT_EQ(StringToGpuSwitchingOption( 14 switches::kGpuSwitchingOptionNameAutomatic), 15 GPU_SWITCHING_OPTION_AUTOMATIC); 16 EXPECT_EQ(StringToGpuSwitchingOption( 17 switches::kGpuSwitchingOptionNameForceDiscrete), 18 GPU_SWITCHING_OPTION_FORCE_DISCRETE); 19 EXPECT_EQ(StringToGpuSwitchingOption( 20 switches::kGpuSwitchingOptionNameForceIntegrated), 21 GPU_SWITCHING_OPTION_FORCE_INTEGRATED); 22 EXPECT_EQ(StringToGpuSwitchingOption("xxx"), GPU_SWITCHING_OPTION_UNKNOWN); 23 } 24 25 TEST(GpuUtilTest, GpuSwitchingOptionToString) { 26 // Test GpuSwitchingOptionToString. 27 EXPECT_STREQ( 28 GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_AUTOMATIC).c_str(), 29 switches::kGpuSwitchingOptionNameAutomatic); 30 EXPECT_STREQ( 31 GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_FORCE_DISCRETE).c_str(), 32 switches::kGpuSwitchingOptionNameForceDiscrete); 33 EXPECT_STREQ( 34 GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_FORCE_INTEGRATED).c_str(), 35 switches::kGpuSwitchingOptionNameForceIntegrated); 36 } 37 38 TEST(GpuUtilTest, MergeFeatureSets) { 39 { 40 // Merge two empty sets. 41 std::set<int> src; 42 std::set<int> dst; 43 EXPECT_TRUE(dst.empty()); 44 MergeFeatureSets(&dst, src); 45 EXPECT_TRUE(dst.empty()); 46 } 47 { 48 // Merge an empty set into a set with elements. 49 std::set<int> src; 50 std::set<int> dst; 51 dst.insert(1); 52 EXPECT_EQ(1u, dst.size()); 53 MergeFeatureSets(&dst, src); 54 EXPECT_EQ(1u, dst.size()); 55 } 56 { 57 // Merge two sets where the source elements are already in the target set. 58 std::set<int> src; 59 std::set<int> dst; 60 src.insert(1); 61 dst.insert(1); 62 EXPECT_EQ(1u, dst.size()); 63 MergeFeatureSets(&dst, src); 64 EXPECT_EQ(1u, dst.size()); 65 } 66 { 67 // Merge two sets with different elements. 68 std::set<int> src; 69 std::set<int> dst; 70 src.insert(1); 71 dst.insert(2); 72 EXPECT_EQ(1u, dst.size()); 73 MergeFeatureSets(&dst, src); 74 EXPECT_EQ(2u, dst.size()); 75 } 76 } 77 78 } // namespace gpu 79