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 "content/browser/gpu/gpu_control_list.h" | 5 #include "content/browser/gpu/gpu_control_list.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace content { | 8 namespace content { |
9 | 9 |
10 class OsInfoTest : public testing::Test { | 10 class OsInfoTest : public testing::Test { |
(...skipping 15 matching lines...) Expand all Loading... |
26 }; | 26 }; |
27 const GpuControlList::OsType os_type[] = { | 27 const GpuControlList::OsType os_type[] = { |
28 GpuControlList::kOsWin, | 28 GpuControlList::kOsWin, |
29 GpuControlList::kOsLinux, | 29 GpuControlList::kOsLinux, |
30 GpuControlList::kOsMacosx, | 30 GpuControlList::kOsMacosx, |
31 GpuControlList::kOsChromeOS, | 31 GpuControlList::kOsChromeOS, |
32 GpuControlList::kOsAndroid, | 32 GpuControlList::kOsAndroid, |
33 GpuControlList::kOsAny | 33 GpuControlList::kOsAny |
34 }; | 34 }; |
35 for (size_t i = 0; i < arraysize(os); ++i) { | 35 for (size_t i = 0; i < arraysize(os); ++i) { |
36 OsInfo info(os[i], "=", "10.6", ""); | 36 OsInfo info(os[i], "=", "10.6", std::string()); |
37 EXPECT_TRUE(info.IsValid()); | 37 EXPECT_TRUE(info.IsValid()); |
38 EXPECT_EQ(os_type[i], info.type()); | 38 EXPECT_EQ(os_type[i], info.type()); |
39 } | 39 } |
40 { | 40 { |
41 OsInfo info("any", "any", "", ""); | 41 OsInfo info("any", "any", std::string(), std::string()); |
42 EXPECT_TRUE(info.IsValid()); | 42 EXPECT_TRUE(info.IsValid()); |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 TEST_F(OsInfoTest, InvalidOsInfo) { | 46 TEST_F(OsInfoTest, InvalidOsInfo) { |
47 const std::string os[] = { | 47 const std::string os[] = { |
48 "win", | 48 "win", |
49 "linux", | 49 "linux", |
50 "macosx", | 50 "macosx", |
51 "chromeos", | 51 "chromeos", |
52 "android", | 52 "android", |
53 "any" | 53 "any" |
54 }; | 54 }; |
55 for (size_t i = 0; i < arraysize(os); ++i) { | 55 for (size_t i = 0; i < arraysize(os); ++i) { |
56 { | 56 { |
57 OsInfo info(os[i], "", "", ""); | 57 OsInfo info(os[i], std::string(), std::string(), std::string()); |
58 EXPECT_FALSE(info.IsValid()); | 58 EXPECT_FALSE(info.IsValid()); |
59 } | 59 } |
60 { | 60 { |
61 OsInfo info(os[i], "=", "", ""); | 61 OsInfo info(os[i], "=", std::string(), std::string()); |
62 EXPECT_FALSE(info.IsValid()); | 62 EXPECT_FALSE(info.IsValid()); |
63 } | 63 } |
64 { | 64 { |
65 OsInfo info(os[i], "", "10.6", ""); | 65 OsInfo info(os[i], std::string(), "10.6", std::string()); |
66 EXPECT_FALSE(info.IsValid()); | 66 EXPECT_FALSE(info.IsValid()); |
67 } | 67 } |
68 } | 68 } |
69 const std::string os_cap[] = { | 69 const std::string os_cap[] = { |
70 "Win", | 70 "Win", |
71 "Linux", | 71 "Linux", |
72 "MacOSX", | 72 "MacOSX", |
73 "ChromeOS", | 73 "ChromeOS", |
74 "Android", | 74 "Android", |
75 }; | 75 }; |
76 for (size_t i = 0; i < arraysize(os_cap); ++i) { | 76 for (size_t i = 0; i < arraysize(os_cap); ++i) { |
77 OsInfo info(os_cap[i], "=", "10.6", ""); | 77 OsInfo info(os_cap[i], "=", "10.6", std::string()); |
78 EXPECT_FALSE(info.IsValid()); | 78 EXPECT_FALSE(info.IsValid()); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 TEST_F(OsInfoTest, OsComparison) { | 82 TEST_F(OsInfoTest, OsComparison) { |
83 { | 83 { |
84 OsInfo info("any", "any", "", ""); | 84 OsInfo info("any", "any", std::string(), std::string()); |
85 const GpuControlList::OsType os_type[] = { | 85 const GpuControlList::OsType os_type[] = { |
86 GpuControlList::kOsWin, | 86 GpuControlList::kOsWin, GpuControlList::kOsLinux, |
87 GpuControlList::kOsLinux, | 87 GpuControlList::kOsMacosx, GpuControlList::kOsChromeOS, |
88 GpuControlList::kOsMacosx, | |
89 GpuControlList::kOsChromeOS, | |
90 GpuControlList::kOsAndroid, | 88 GpuControlList::kOsAndroid, |
91 }; | 89 }; |
92 for (size_t i = 0; i < arraysize(os_type); ++i) { | 90 for (size_t i = 0; i < arraysize(os_type); ++i) { |
93 EXPECT_TRUE(info.Contains(os_type[i], "")); | 91 EXPECT_TRUE(info.Contains(os_type[i], std::string())); |
94 EXPECT_TRUE(info.Contains(os_type[i], "7.8")); | 92 EXPECT_TRUE(info.Contains(os_type[i], "7.8")); |
95 } | 93 } |
96 } | 94 } |
97 { | 95 { |
98 OsInfo info("win", ">=", "6", ""); | 96 OsInfo info("win", ">=", "6", std::string()); |
99 EXPECT_FALSE(info.Contains(GpuControlList::kOsMacosx, "10.8.3")); | 97 EXPECT_FALSE(info.Contains(GpuControlList::kOsMacosx, "10.8.3")); |
100 EXPECT_FALSE(info.Contains(GpuControlList::kOsLinux, "10")); | 98 EXPECT_FALSE(info.Contains(GpuControlList::kOsLinux, "10")); |
101 EXPECT_FALSE(info.Contains(GpuControlList::kOsChromeOS, "13")); | 99 EXPECT_FALSE(info.Contains(GpuControlList::kOsChromeOS, "13")); |
102 EXPECT_FALSE(info.Contains(GpuControlList::kOsAndroid, "7")); | 100 EXPECT_FALSE(info.Contains(GpuControlList::kOsAndroid, "7")); |
103 EXPECT_FALSE(info.Contains(GpuControlList::kOsAny, "7")); | 101 EXPECT_FALSE(info.Contains(GpuControlList::kOsAny, "7")); |
104 EXPECT_FALSE(info.Contains(GpuControlList::kOsWin, "")); | 102 EXPECT_FALSE(info.Contains(GpuControlList::kOsWin, std::string())); |
105 EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "6")); | 103 EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "6")); |
106 EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "6.1")); | 104 EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "6.1")); |
107 EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "7")); | 105 EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "7")); |
108 EXPECT_FALSE(info.Contains(GpuControlList::kOsWin, "5")); | 106 EXPECT_FALSE(info.Contains(GpuControlList::kOsWin, "5")); |
109 } | 107 } |
110 } | 108 } |
111 | 109 |
112 } // namespace content | 110 } // namespace content |
113 | 111 |
OLD | NEW |