Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(371)

Side by Side Diff: content/browser/gpu/gpu_control_list_number_info_unittest.cc

Issue 15385003: Move GPU device/driver info related code from content to gpu. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 NumberInfoTest : public testing::Test {
11 public:
12 NumberInfoTest() { }
13 virtual ~NumberInfoTest() { }
14
15 typedef GpuControlList::FloatInfo FloatInfo;
16 typedef GpuControlList::IntInfo IntInfo;
17 };
18
19 TEST_F(NumberInfoTest, ValidFloatInfo) {
20 const std::string op[] = {
21 "=",
22 "<",
23 "<=",
24 ">",
25 ">=",
26 "any",
27 "between"
28 };
29 for (size_t i = 0; i < arraysize(op); ++i) {
30 std::string value1;
31 std::string value2;
32 if (op[i] != "any")
33 value1 = "3.14";
34 if (op[i] == "between")
35 value2 = "4.21";
36 FloatInfo info(op[i], value1, value2);
37 EXPECT_TRUE(info.IsValid());
38 }
39
40 const std::string value[] = {
41 "1.0E12",
42 "1.0e12",
43 "2013",
44 "1.0e-12",
45 "2.1400",
46 "-2.14",
47 };
48 for (size_t i = 0; i < arraysize(value); ++i) {
49 FloatInfo info("=", value[i], std::string());
50 EXPECT_TRUE(info.IsValid());
51 }
52 }
53
54 TEST_F(NumberInfoTest, InvalidFloatInfo) {
55 const std::string op[] = {
56 "=",
57 "<",
58 "<=",
59 ">",
60 ">=",
61 };
62 for (size_t i = 0; i < arraysize(op); ++i) {
63 FloatInfo info(op[i], std::string(), std::string());
64 EXPECT_FALSE(info.IsValid());
65 }
66 {
67 FloatInfo info("between", "3.14", std::string());
68 EXPECT_FALSE(info.IsValid());
69 }
70 const std::string value[] = {
71 "1.0 E12",
72 "1.0e 12",
73 " 2013",
74 "2013 ",
75 "- 2.14",
76 };
77 for (size_t i = 0; i < arraysize(value); ++i) {
78 FloatInfo info("=", value[i], std::string());
79 EXPECT_FALSE(info.IsValid());
80 }
81 }
82
83 TEST_F(NumberInfoTest, FloatComparison) {
84 {
85 FloatInfo info("=", "3.14", std::string());
86 EXPECT_TRUE(info.Contains(3.14f));
87 EXPECT_TRUE(info.Contains(3.1400f));
88 EXPECT_FALSE(info.Contains(3.1f));
89 EXPECT_FALSE(info.Contains(3));
90 }
91 {
92 FloatInfo info(">", "3.14", std::string());
93 EXPECT_FALSE(info.Contains(3.14f));
94 EXPECT_TRUE(info.Contains(3.141f));
95 EXPECT_FALSE(info.Contains(3.1f));
96 }
97 {
98 FloatInfo info("<=", "3.14", std::string());
99 EXPECT_TRUE(info.Contains(3.14f));
100 EXPECT_FALSE(info.Contains(3.141f));
101 EXPECT_TRUE(info.Contains(3.1f));
102 }
103 {
104 FloatInfo info("any", std::string(), std::string());
105 EXPECT_TRUE(info.Contains(3.14f));
106 }
107 {
108 FloatInfo info("between", "3.14", "5.4");
109 EXPECT_TRUE(info.Contains(3.14f));
110 EXPECT_TRUE(info.Contains(5.4f));
111 EXPECT_TRUE(info.Contains(4));
112 EXPECT_FALSE(info.Contains(5.6f));
113 EXPECT_FALSE(info.Contains(3.12f));
114 }
115 }
116
117 TEST_F(NumberInfoTest, ValidIntInfo) {
118 const std::string op[] = {
119 "=",
120 "<",
121 "<=",
122 ">",
123 ">=",
124 "any",
125 "between"
126 };
127 for (size_t i = 0; i < arraysize(op); ++i) {
128 std::string value1;
129 std::string value2;
130 if (op[i] != "any")
131 value1 = "3";
132 if (op[i] == "between")
133 value2 = "9";
134 IntInfo info(op[i], value1, value2);
135 EXPECT_TRUE(info.IsValid());
136 }
137
138 const std::string value[] = {
139 "12",
140 "-12",
141 };
142 for (size_t i = 0; i < arraysize(value); ++i) {
143 IntInfo info("=", value[i], std::string());
144 EXPECT_TRUE(info.IsValid());
145 }
146 }
147
148 TEST_F(NumberInfoTest, InvalidIntInfo) {
149 const std::string op[] = {
150 "=",
151 "<",
152 "<=",
153 ">",
154 ">=",
155 };
156 for (size_t i = 0; i < arraysize(op); ++i) {
157 IntInfo info(op[i], std::string(), std::string());
158 EXPECT_FALSE(info.IsValid());
159 }
160 {
161 IntInfo info("between", "3", std::string());
162 EXPECT_FALSE(info.IsValid());
163 }
164 const std::string value[] = {
165 " 12",
166 "12 ",
167 "- 12",
168 " -12",
169 "3.14"
170 };
171 for (size_t i = 0; i < arraysize(value); ++i) {
172 IntInfo info("=", value[i], std::string());
173 EXPECT_FALSE(info.IsValid());
174 }
175 }
176
177 TEST_F(NumberInfoTest, IntComparison) {
178 {
179 IntInfo info("=", "3", std::string());
180 EXPECT_TRUE(info.Contains(3));
181 EXPECT_FALSE(info.Contains(4));
182 }
183 {
184 IntInfo info(">", "3", std::string());
185 EXPECT_FALSE(info.Contains(2));
186 EXPECT_FALSE(info.Contains(3));
187 EXPECT_TRUE(info.Contains(4));
188 }
189 {
190 IntInfo info("<=", "3", std::string());
191 EXPECT_TRUE(info.Contains(2));
192 EXPECT_TRUE(info.Contains(3));
193 EXPECT_FALSE(info.Contains(4));
194 }
195 {
196 IntInfo info("any", std::string(), std::string());
197 EXPECT_TRUE(info.Contains(3));
198 }
199 {
200 IntInfo info("between", "3", "5");
201 EXPECT_TRUE(info.Contains(3));
202 EXPECT_TRUE(info.Contains(5));
203 EXPECT_TRUE(info.Contains(4));
204 EXPECT_FALSE(info.Contains(6));
205 EXPECT_FALSE(info.Contains(2));
206 }
207 }
208
209 } // namespace content
210
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698