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
, OsComparison
) {
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
,
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"));
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"));