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.
5 #include "gpu/config/gpu_control_list.h"
6 #include "testing/gtest/include/gtest/gtest.h"
10 class OsInfoTest
: public testing::Test
{
13 virtual ~OsInfoTest() { }
15 typedef GpuControlList::OsInfo OsInfo
;
18 TEST_F(OsInfoTest
, ValidOsInfo
) {
19 const std::string os
[] = {
27 const GpuControlList::OsType os_type
[] = {
28 GpuControlList::kOsWin
,
29 GpuControlList::kOsLinux
,
30 GpuControlList::kOsMacosx
,
31 GpuControlList::kOsChromeOS
,
32 GpuControlList::kOsAndroid
,
33 GpuControlList::kOsAny
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());
41 OsInfo
info("any", "any", std::string(), std::string());
42 EXPECT_TRUE(info
.IsValid());
46 TEST_F(OsInfoTest
, InvalidOsInfo
) {
47 const std::string os
[] = {
55 for (size_t i
= 0; i
< arraysize(os
); ++i
) {
57 OsInfo
info(os
[i
], std::string(), std::string(), std::string());
58 EXPECT_FALSE(info
.IsValid());
61 OsInfo
info(os
[i
], "=", std::string(), std::string());
62 EXPECT_FALSE(info
.IsValid());
65 OsInfo
info(os
[i
], std::string(), "10.6", std::string());
66 EXPECT_FALSE(info
.IsValid());
69 const std::string os_cap
[] = {
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());
82 TEST_F(OsInfoTest
, NonNumericOsVersion
) {
84 OsInfo
info("android", "<", "4.2", std::string());
85 EXPECT_TRUE(info
.IsValid());
86 // The expectation is the version number first, then extra info.
87 EXPECT_TRUE(info
.Contains(
88 GpuControlList::kOsAndroid
, "4.0 bug fix version 5.2"));
89 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAndroid
, "F"));
90 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAndroid
, "F 4.0"));
91 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAndroid
, std::string()));
94 OsInfo
info("android", "any", std::string(), std::string());
95 EXPECT_TRUE(info
.IsValid());
96 EXPECT_TRUE(info
.Contains(
97 GpuControlList::kOsAndroid
, "4.0 bug fix version 5.2"));
98 EXPECT_TRUE(info
.Contains(GpuControlList::kOsAndroid
, "F"));
99 EXPECT_TRUE(info
.Contains(GpuControlList::kOsAndroid
, "F 4.0"));
100 EXPECT_TRUE(info
.Contains(GpuControlList::kOsAndroid
, std::string()));
104 TEST_F(OsInfoTest
, OsVersionZero
) {
106 OsInfo
info("android", "<", "4.2", std::string());
107 EXPECT_TRUE(info
.IsValid());
108 // All forms of version 0 is considered invalid.
109 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAndroid
, "0"));
110 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAndroid
, "0.0"));
111 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAndroid
, "0.00.0"));
114 OsInfo
info("android", "any", std::string(), std::string());
115 EXPECT_TRUE(info
.IsValid());
116 EXPECT_TRUE(info
.Contains(GpuControlList::kOsAndroid
, "0"));
117 EXPECT_TRUE(info
.Contains(GpuControlList::kOsAndroid
, "0.0"));
118 EXPECT_TRUE(info
.Contains(GpuControlList::kOsAndroid
, "0.00.0"));
122 TEST_F(OsInfoTest
, OsComparison
) {
124 OsInfo
info("any", "any", std::string(), std::string());
125 const GpuControlList::OsType os_type
[] = {
126 GpuControlList::kOsWin
, GpuControlList::kOsLinux
,
127 GpuControlList::kOsMacosx
, GpuControlList::kOsChromeOS
,
128 GpuControlList::kOsAndroid
,
130 for (size_t i
= 0; i
< arraysize(os_type
); ++i
) {
131 EXPECT_TRUE(info
.Contains(os_type
[i
], std::string()));
132 EXPECT_TRUE(info
.Contains(os_type
[i
], "7.8"));
136 OsInfo
info("win", ">=", "6", std::string());
137 EXPECT_FALSE(info
.Contains(GpuControlList::kOsMacosx
, "10.8.3"));
138 EXPECT_FALSE(info
.Contains(GpuControlList::kOsLinux
, "10"));
139 EXPECT_FALSE(info
.Contains(GpuControlList::kOsChromeOS
, "13"));
140 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAndroid
, "7"));
141 EXPECT_FALSE(info
.Contains(GpuControlList::kOsAny
, "7"));
142 EXPECT_FALSE(info
.Contains(GpuControlList::kOsWin
, std::string()));
143 EXPECT_TRUE(info
.Contains(GpuControlList::kOsWin
, "6"));
144 EXPECT_TRUE(info
.Contains(GpuControlList::kOsWin
, "6.1"));
145 EXPECT_TRUE(info
.Contains(GpuControlList::kOsWin
, "7"));
146 EXPECT_FALSE(info
.Contains(GpuControlList::kOsWin
, "5"));