OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1194 |
1195 scoped_ptr<GpuBlacklist> blacklist(Create()); | 1195 scoped_ptr<GpuBlacklist> blacklist(Create()); |
1196 EXPECT_TRUE(blacklist->LoadGpuBlacklist( | 1196 EXPECT_TRUE(blacklist->LoadGpuBlacklist( |
1197 video_json, GpuBlacklist::kAllOs)); | 1197 video_json, GpuBlacklist::kAllOs)); |
1198 GpuFeatureType type = blacklist->MakeBlacklistDecision( | 1198 GpuFeatureType type = blacklist->MakeBlacklistDecision( |
1199 GpuBlacklist::kOsMacosx, &os_version, | 1199 GpuBlacklist::kOsMacosx, &os_version, |
1200 gpu_info()).blacklisted_features; | 1200 gpu_info()).blacklisted_features; |
1201 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO); | 1201 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_VIDEO); |
1202 } | 1202 } |
1203 | 1203 |
| 1204 TEST_F(GpuBlacklistTest, NeedsMoreInfo) { |
| 1205 const std::string json = |
| 1206 "{\n" |
| 1207 " \"name\": \"gpu blacklist\",\n" |
| 1208 " \"version\": \"0.1\",\n" |
| 1209 " \"entries\": [\n" |
| 1210 " {\n" |
| 1211 " \"id\": 1,\n" |
| 1212 " \"os\": {\n" |
| 1213 " \"type\": \"linux\"\n" |
| 1214 " },\n" |
| 1215 " \"vendor_id\": \"0x8086\",\n" |
| 1216 " \"driver_version\": {\n" |
| 1217 " \"op\": \"<\",\n" |
| 1218 " \"number\": \"10.7\"\n" |
| 1219 " },\n" |
| 1220 " \"blacklist\": [\n" |
| 1221 " \"webgl\"\n" |
| 1222 " ]\n" |
| 1223 " }\n" |
| 1224 " ]\n" |
| 1225 "}"; |
| 1226 |
| 1227 content::GPUInfo gpu_info; |
| 1228 gpu_info.gpu.vendor_id = 0x8086; |
| 1229 |
| 1230 Version os_version("10.7"); |
| 1231 scoped_ptr<GpuBlacklist> blacklist(Create()); |
| 1232 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); |
| 1233 |
| 1234 // The case this entry does not apply. |
| 1235 GpuFeatureType type = blacklist->MakeBlacklistDecision( |
| 1236 GpuBlacklist::kOsMacosx, &os_version, |
| 1237 gpu_info).blacklisted_features; |
| 1238 EXPECT_EQ(0, type); |
| 1239 EXPECT_FALSE(blacklist->needs_more_info()); |
| 1240 |
| 1241 // The case this entry might apply, but need more info. |
| 1242 type = blacklist->MakeBlacklistDecision( |
| 1243 GpuBlacklist::kOsLinux, &os_version, |
| 1244 gpu_info).blacklisted_features; |
| 1245 EXPECT_EQ(0, type); |
| 1246 EXPECT_TRUE(blacklist->needs_more_info()); |
| 1247 |
| 1248 // The case we have full info, and this entry applies. |
| 1249 gpu_info.driver_version = "10.6"; |
| 1250 type = blacklist->MakeBlacklistDecision( |
| 1251 GpuBlacklist::kOsLinux, &os_version, |
| 1252 gpu_info).blacklisted_features; |
| 1253 EXPECT_EQ(content::GPU_FEATURE_TYPE_WEBGL, type); |
| 1254 EXPECT_FALSE(blacklist->needs_more_info()); |
| 1255 |
| 1256 // The case we have full info, and this entry does not apply. |
| 1257 gpu_info.driver_version = "10.8"; |
| 1258 type = blacklist->MakeBlacklistDecision( |
| 1259 GpuBlacklist::kOsLinux, &os_version, |
| 1260 gpu_info).blacklisted_features; |
| 1261 EXPECT_EQ(0, type); |
| 1262 EXPECT_FALSE(blacklist->needs_more_info()); |
| 1263 } |
| 1264 |
| 1265 TEST_F(GpuBlacklistTest, NeedsMoreInfoForExceptions) { |
| 1266 const std::string json = |
| 1267 "{\n" |
| 1268 " \"name\": \"gpu blacklist\",\n" |
| 1269 " \"version\": \"0.1\",\n" |
| 1270 " \"entries\": [\n" |
| 1271 " {\n" |
| 1272 " \"id\": 1,\n" |
| 1273 " \"os\": {\n" |
| 1274 " \"type\": \"linux\"\n" |
| 1275 " },\n" |
| 1276 " \"vendor_id\": \"0x8086\",\n" |
| 1277 " \"exceptions\": [\n" |
| 1278 " {\n" |
| 1279 " \"gl_renderer\": {\n" |
| 1280 " \"op\": \"contains\",\n" |
| 1281 " \"value\": \"mesa\"\n" |
| 1282 " }\n" |
| 1283 " }\n" |
| 1284 " ],\n" |
| 1285 " \"blacklist\": [\n" |
| 1286 " \"webgl\"\n" |
| 1287 " ]\n" |
| 1288 " }\n" |
| 1289 " ]\n" |
| 1290 "}"; |
| 1291 |
| 1292 content::GPUInfo gpu_info; |
| 1293 gpu_info.gpu.vendor_id = 0x8086; |
| 1294 |
| 1295 Version os_version("10.7"); |
| 1296 scoped_ptr<GpuBlacklist> blacklist(Create()); |
| 1297 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); |
| 1298 |
| 1299 // The case this entry does not apply. |
| 1300 GpuFeatureType type = blacklist->MakeBlacklistDecision( |
| 1301 GpuBlacklist::kOsMacosx, &os_version, |
| 1302 gpu_info).blacklisted_features; |
| 1303 EXPECT_EQ(0, type); |
| 1304 EXPECT_FALSE(blacklist->needs_more_info()); |
| 1305 |
| 1306 // The case this entry might apply, but need more info. |
| 1307 type = blacklist->MakeBlacklistDecision( |
| 1308 GpuBlacklist::kOsLinux, &os_version, |
| 1309 gpu_info).blacklisted_features; |
| 1310 EXPECT_EQ(0, type); |
| 1311 EXPECT_TRUE(blacklist->needs_more_info()); |
| 1312 |
| 1313 // The case we have full info, and the exception applies (so the entry |
| 1314 // does not apply). |
| 1315 gpu_info.gl_renderer = "mesa"; |
| 1316 type = blacklist->MakeBlacklistDecision( |
| 1317 GpuBlacklist::kOsLinux, &os_version, |
| 1318 gpu_info).blacklisted_features; |
| 1319 EXPECT_EQ(0, type); |
| 1320 EXPECT_FALSE(blacklist->needs_more_info()); |
| 1321 |
| 1322 // The case we have full info, and this entry applies. |
| 1323 gpu_info.gl_renderer = "my renderer"; |
| 1324 type = blacklist->MakeBlacklistDecision( |
| 1325 GpuBlacklist::kOsLinux, &os_version, |
| 1326 gpu_info).blacklisted_features; |
| 1327 EXPECT_EQ(content::GPU_FEATURE_TYPE_WEBGL, type); |
| 1328 EXPECT_FALSE(blacklist->needs_more_info()); |
| 1329 } |
| 1330 |
| 1331 TEST_F(GpuBlacklistTest, IgnorableEntries) { |
| 1332 // If an entry will not change the blacklist decisions, then it should not |
| 1333 // trigger the needs_more_info flag. |
| 1334 const std::string json = |
| 1335 "{\n" |
| 1336 " \"name\": \"gpu blacklist\",\n" |
| 1337 " \"version\": \"0.1\",\n" |
| 1338 " \"entries\": [\n" |
| 1339 " {\n" |
| 1340 " \"id\": 1,\n" |
| 1341 " \"os\": {\n" |
| 1342 " \"type\": \"linux\"\n" |
| 1343 " },\n" |
| 1344 " \"vendor_id\": \"0x8086\",\n" |
| 1345 " \"blacklist\": [\n" |
| 1346 " \"webgl\"\n" |
| 1347 " ]\n" |
| 1348 " },\n" |
| 1349 " {\n" |
| 1350 " \"id\": 2,\n" |
| 1351 " \"os\": {\n" |
| 1352 " \"type\": \"linux\"\n" |
| 1353 " },\n" |
| 1354 " \"vendor_id\": \"0x8086\",\n" |
| 1355 " \"driver_version\": {\n" |
| 1356 " \"op\": \"<\",\n" |
| 1357 " \"number\": \"10.7\"\n" |
| 1358 " },\n" |
| 1359 " \"blacklist\": [\n" |
| 1360 " \"webgl\"\n" |
| 1361 " ]\n" |
| 1362 " }\n" |
| 1363 " ]\n" |
| 1364 "}"; |
| 1365 |
| 1366 content::GPUInfo gpu_info; |
| 1367 gpu_info.gpu.vendor_id = 0x8086; |
| 1368 |
| 1369 Version os_version("10.7"); |
| 1370 scoped_ptr<GpuBlacklist> blacklist(Create()); |
| 1371 EXPECT_TRUE(blacklist->LoadGpuBlacklist(json, GpuBlacklist::kAllOs)); |
| 1372 GpuFeatureType type = blacklist->MakeBlacklistDecision( |
| 1373 GpuBlacklist::kOsLinux, &os_version, |
| 1374 gpu_info).blacklisted_features; |
| 1375 EXPECT_EQ(content::GPU_FEATURE_TYPE_WEBGL, type); |
| 1376 EXPECT_FALSE(blacklist->needs_more_info()); |
| 1377 } |
| 1378 |
OLD | NEW |