forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpu_control_list_os_info_unittest.cc
111 lines (102 loc) · 3.02 KB
/
gpu_control_list_os_info_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gpu/config/gpu_control_list.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace gpu {
class OsInfoTest : public testing::Test {
public:
OsInfoTest() { }
virtual ~OsInfoTest() { }
typedef GpuControlList::OsInfo OsInfo;
};
TEST_F(OsInfoTest, ValidOsInfo) {
const std::string os[] = {
"win",
"linux",
"macosx",
"chromeos",
"android",
"any"
};
const GpuControlList::OsType os_type[] = {
GpuControlList::kOsWin,
GpuControlList::kOsLinux,
GpuControlList::kOsMacosx,
GpuControlList::kOsChromeOS,
GpuControlList::kOsAndroid,
GpuControlList::kOsAny
};
for (size_t i = 0; i < arraysize(os); ++i) {
OsInfo info(os[i], "=", "10.6", std::string());
EXPECT_TRUE(info.IsValid());
EXPECT_EQ(os_type[i], info.type());
}
{
OsInfo info("any", "any", std::string(), std::string());
EXPECT_TRUE(info.IsValid());
}
}
TEST_F(OsInfoTest, InvalidOsInfo) {
const std::string os[] = {
"win",
"linux",
"macosx",
"chromeos",
"android",
"any"
};
for (size_t i = 0; i < arraysize(os); ++i) {
{
OsInfo info(os[i], std::string(), std::string(), std::string());
EXPECT_FALSE(info.IsValid());
}
{
OsInfo info(os[i], "=", std::string(), std::string());
EXPECT_FALSE(info.IsValid());
}
{
OsInfo info(os[i], std::string(), "10.6", std::string());
EXPECT_FALSE(info.IsValid());
}
}
const std::string os_cap[] = {
"Win",
"Linux",
"MacOSX",
"ChromeOS",
"Android",
};
for (size_t i = 0; i < arraysize(os_cap); ++i) {
OsInfo info(os_cap[i], "=", "10.6", std::string());
EXPECT_FALSE(info.IsValid());
}
}
TEST_F(OsInfoTest, OsComparison) {
{
OsInfo info("any", "any", std::string(), std::string());
const GpuControlList::OsType os_type[] = {
GpuControlList::kOsWin, GpuControlList::kOsLinux,
GpuControlList::kOsMacosx, GpuControlList::kOsChromeOS,
GpuControlList::kOsAndroid,
};
for (size_t i = 0; i < arraysize(os_type); ++i) {
EXPECT_TRUE(info.Contains(os_type[i], std::string()));
EXPECT_TRUE(info.Contains(os_type[i], "7.8"));
}
}
{
OsInfo info("win", ">=", "6", std::string());
EXPECT_FALSE(info.Contains(GpuControlList::kOsMacosx, "10.8.3"));
EXPECT_FALSE(info.Contains(GpuControlList::kOsLinux, "10"));
EXPECT_FALSE(info.Contains(GpuControlList::kOsChromeOS, "13"));
EXPECT_FALSE(info.Contains(GpuControlList::kOsAndroid, "7"));
EXPECT_FALSE(info.Contains(GpuControlList::kOsAny, "7"));
EXPECT_FALSE(info.Contains(GpuControlList::kOsWin, std::string()));
EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "6"));
EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "6.1"));
EXPECT_TRUE(info.Contains(GpuControlList::kOsWin, "7"));
EXPECT_FALSE(info.Contains(GpuControlList::kOsWin, "5"));
}
}
} // namespace gpu