Index: gpu/config/gpu_control_list_entry_unittest.cc |
diff --git a/gpu/config/gpu_control_list_entry_unittest.cc b/gpu/config/gpu_control_list_entry_unittest.cc |
index 6ae866b7747d127a15a7d8b56be081e269055293..13620c6aa14de09c6698113b0f96e6befca55714 100644 |
--- a/gpu/config/gpu_control_list_entry_unittest.cc |
+++ b/gpu/config/gpu_control_list_entry_unittest.cc |
@@ -470,14 +470,11 @@ TEST_F(GpuControlListEntryTest, GlVersionGLEntry) { |
EXPECT_FALSE(entry->Contains(GpuControlList::kOsWin, "6.1", gpu_info)); |
} |
-TEST_F(GpuControlListEntryTest, GlVendorEntry) { |
+TEST_F(GpuControlListEntryTest, GlVendorEqual) { |
const std::string json = LONG_STRING_CONST( |
{ |
"id": 1, |
- "gl_vendor": { |
- "op": "beginwith", |
- "value": "NVIDIA" |
- }, |
+ "gl_vendor": "NVIDIA", |
"features": [ |
"test_feature_0" |
] |
@@ -486,25 +483,26 @@ TEST_F(GpuControlListEntryTest, GlVendorEntry) { |
ScopedEntry entry(GetEntryFromString(json)); |
EXPECT_TRUE(entry.get() != NULL); |
- const GpuControlList::OsType os_type[] = { |
- GpuControlList::kOsMacosx, |
- GpuControlList::kOsWin, |
- GpuControlList::kOsLinux, |
- GpuControlList::kOsChromeOS, |
- GpuControlList::kOsAndroid |
- }; |
- for (size_t i = 0; i < arraysize(os_type); ++i) |
- EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info())); |
+ GPUInfo gpu_info; |
+ gpu_info.gl_vendor = "NVIDIA"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ // Case insensitive. |
+ gpu_info.gl_vendor = "NVidia"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ gpu_info.gl_vendor = "NVIDIA-x"; |
+ EXPECT_FALSE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
} |
-TEST_F(GpuControlListEntryTest, GlRendererEntry) { |
+TEST_F(GpuControlListEntryTest, GlVendorWithDot) { |
const std::string json = LONG_STRING_CONST( |
{ |
"id": 1, |
- "gl_renderer": { |
- "op": "contains", |
- "value": "GeForce" |
- }, |
+ "gl_vendor": "X\\.Org.*", |
"features": [ |
"test_feature_0" |
] |
@@ -513,15 +511,77 @@ TEST_F(GpuControlListEntryTest, GlRendererEntry) { |
ScopedEntry entry(GetEntryFromString(json)); |
EXPECT_TRUE(entry.get() != NULL); |
- const GpuControlList::OsType os_type[] = { |
- GpuControlList::kOsMacosx, |
- GpuControlList::kOsWin, |
- GpuControlList::kOsLinux, |
- GpuControlList::kOsChromeOS, |
- GpuControlList::kOsAndroid |
- }; |
- for (size_t i = 0; i < arraysize(os_type); ++i) |
- EXPECT_TRUE(entry->Contains(os_type[i], "10.6", gpu_info())); |
+ GPUInfo gpu_info; |
+ gpu_info.gl_vendor = "X.Org R300 Project"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsLinux, "", gpu_info)); |
+ |
+ gpu_info.gl_vendor = "X.Org"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsLinux, "", gpu_info)); |
+} |
+ |
+TEST_F(GpuControlListEntryTest, GlRendererContains) { |
+ const std::string json = LONG_STRING_CONST( |
+ { |
+ "id": 1, |
+ "gl_renderer": ".*GeForce.*", |
+ "features": [ |
+ "test_feature_0" |
+ ] |
+ } |
+ ); |
+ ScopedEntry entry(GetEntryFromString(json)); |
+ EXPECT_TRUE(entry.get() != NULL); |
+ |
+ GPUInfo gpu_info; |
+ gpu_info.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ // Case insensitive. |
+ gpu_info.gl_renderer = "NVIDIA GEFORCE GT 120 OpenGL Engine"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ gpu_info.gl_renderer = "GeForce GT 120 OpenGL Engine"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ gpu_info.gl_renderer = "NVIDIA GeForce"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ gpu_info.gl_renderer = "NVIDIA Ge Force"; |
+ EXPECT_FALSE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+} |
+ |
+TEST_F(GpuControlListEntryTest, GlExtensionsEndWith) { |
+ const std::string json = LONG_STRING_CONST( |
+ { |
+ "id": 1, |
+ "gl_extensions": ".*GL_SUN_slice_accum", |
+ "features": [ |
+ "test_feature_0" |
+ ] |
+ } |
+ ); |
+ ScopedEntry entry(GetEntryFromString(json)); |
+ EXPECT_TRUE(entry.get() != NULL); |
+ |
+ GPUInfo gpu_info; |
+ gpu_info.gl_extensions = "GL_SGIS_generate_mipmap " |
+ "GL_SGIX_shadow " |
+ "GL_SUN_slice_accum"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ gpu_info.gl_extensions = "GL_SGIS_generate_mipmap " |
+ "GL_SUN_slice_accum " |
+ "GL_SGIX_shadow"; |
+ EXPECT_FALSE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
} |
TEST_F(GpuControlListEntryTest, PerfGraphicsEntry) { |
@@ -640,6 +700,38 @@ TEST_F(GpuControlListEntryTest, AMDSwitchableEntry) { |
GpuControlList::kOsMacosx, "10.6", gpu_info)); |
} |
+TEST_F(GpuControlListEntryTest, DriverVendorBeginWith) { |
+ const std::string json = LONG_STRING_CONST( |
+ { |
+ "id": 1, |
+ "driver_vendor": "NVIDIA.*", |
+ "features": [ |
+ "test_feature_0" |
+ ] |
+ } |
+ ); |
+ ScopedEntry entry(GetEntryFromString(json)); |
+ EXPECT_TRUE(entry.get() != NULL); |
+ |
+ GPUInfo gpu_info; |
+ gpu_info.driver_vendor = "NVIDIA Corporation"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ // Case insensitive. |
+ gpu_info.driver_vendor = "NVidia Corporation"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ gpu_info.driver_vendor = "NVIDIA"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+ |
+ gpu_info.driver_vendor = "USA NVIDIA"; |
+ EXPECT_FALSE(entry->Contains( |
+ GpuControlList::kOsMacosx, "10.9", gpu_info)); |
+} |
+ |
TEST_F(GpuControlListEntryTest, LexicalDriverVersionEntry) { |
const std::string json = LONG_STRING_CONST( |
{ |
@@ -710,10 +802,7 @@ TEST_F(GpuControlListEntryTest, NeedsMoreInfoForExceptionsEntry) { |
"vendor_id": "0x8086", |
"exceptions": [ |
{ |
- "gl_renderer": { |
- "op": "contains", |
- "value": "mesa" |
- } |
+ "gl_renderer": ".*mesa.*" |
} |
], |
"features": [ |
@@ -807,7 +896,9 @@ TEST_F(GpuControlListEntryTest, MachineModelName) { |
"os": { |
"type": "android" |
}, |
- "machine_model_name": ["Nexus 4", "XT1032"], |
+ "machine_model_name": [ |
+ "Nexus 4", "XT1032", "GT-.*", "SCH-.*" |
+ ], |
"features": [ |
"test_feature_0" |
] |
@@ -841,6 +932,18 @@ TEST_F(GpuControlListEntryTest, MachineModelName) { |
gpu_info.machine_model_name = ""; |
EXPECT_FALSE(entry->Contains( |
GpuControlList::kOsAndroid, "4.1", gpu_info)); |
+ |
+ gpu_info.machine_model_name = "GT-N7100"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsAndroid, "4.1", gpu_info)); |
+ |
+ gpu_info.machine_model_name = "GT-I9300"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsAndroid, "4.1", gpu_info)); |
+ |
+ gpu_info.machine_model_name = "SCH-I545"; |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsAndroid, "4.1", gpu_info)); |
} |
TEST_F(GpuControlListEntryTest, MachineModelNameException) { |
@@ -852,7 +955,7 @@ TEST_F(GpuControlListEntryTest, MachineModelNameException) { |
"os": { |
"type": "android" |
}, |
- "machine_model_name": ["Nexus 4"] |
+ "machine_model_name": ["Nexus.*"] |
} |
], |
"features": [ |
@@ -871,6 +974,12 @@ TEST_F(GpuControlListEntryTest, MachineModelNameException) { |
EXPECT_TRUE(entry->Contains( |
GpuControlList::kOsLinux, "4.1", gpu_info)); |
+ gpu_info.machine_model_name = "Nexus 7"; |
+ EXPECT_FALSE(entry->Contains( |
+ GpuControlList::kOsAndroid, "4.1", gpu_info)); |
+ EXPECT_TRUE(entry->Contains( |
+ GpuControlList::kOsLinux, "4.1", gpu_info)); |
+ |
gpu_info.machine_model_name = ""; |
EXPECT_TRUE(entry->Contains( |
GpuControlList::kOsAndroid, "4.1", gpu_info)); |