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