summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authortobiasjs <tobiasjs@chromium.org>2015-06-05 05:38:11 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-05 12:38:47 +0000
commitf9268969d2516c5748ba4b76d716ad0844390ed8 (patch)
tree3f81b478fca0cde17e76bdbd565b198f571986af /gpu
parent4d306ff30b22ca6c7741ad996c101b7ce2a61965 (diff)
downloadchromium_src-f9268969d2516c5748ba4b76d716ad0844390ed8.zip
chromium_src-f9268969d2516c5748ba4b76d716ad0844390ed8.tar.gz
chromium_src-f9268969d2516c5748ba4b76d716ad0844390ed8.tar.bz2
Add tests for Android GL driver version extraction.
BUG=481955 Review URL: https://codereview.chromium.org/1160293004 Cr-Commit-Position: refs/heads/master@{#333038}
Diffstat (limited to 'gpu')
-rw-r--r--gpu/config/gpu_info_collector_android.cc11
-rw-r--r--gpu/config/gpu_info_collector_unittest.cc71
2 files changed, 78 insertions, 4 deletions
diff --git a/gpu/config/gpu_info_collector_android.cc b/gpu/config/gpu_info_collector_android.cc
index 97a79e5..d05e85b 100644
--- a/gpu/config/gpu_info_collector_android.cc
+++ b/gpu/config/gpu_info_collector_android.cc
@@ -18,10 +18,13 @@
namespace {
std::string GetDriverVersionFromString(const std::string& version_string) {
- // Extract driver version from the second number in a string like:
- // "OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)"
-
- // Exclude first "2.0".
+ // We expect that android GL_VERSION strings will be of a form
+ // similar to: "OpenGL ES 2.0 V@6.0 AU@ (CL@2946718)" where the
+ // first match to [0-9][0-9.]* is the OpenGL ES version number, and
+ // the second match to [0-9][0-9.]* is the driver version (in this
+ // case, 6.0).
+ // It is currently assumed that the driver version has at least one
+ // period in it, and only the first two components are significant.
size_t begin = version_string.find_first_of("0123456789");
if (begin == std::string::npos)
return "0";
diff --git a/gpu/config/gpu_info_collector_unittest.cc b/gpu/config/gpu_info_collector_unittest.cc
index 359461a..f89eb4d 100644
--- a/gpu/config/gpu_info_collector_unittest.cc
+++ b/gpu/config/gpu_info_collector_unittest.cc
@@ -151,5 +151,76 @@ TEST_F(GPUInfoCollectorTest, CollectGraphicsInfoGL) {
EXPECT_EQ(test_values_.gl_extensions, gpu_info.gl_extensions);
}
+class CollectDriverInfoGLTest : public testing::Test {
+ public:
+ CollectDriverInfoGLTest() {}
+ ~CollectDriverInfoGLTest() override {}
+
+ void SetUp() override {}
+ void TearDown() override {}
+};
+
+TEST_F(CollectDriverInfoGLTest, CollectDriverInfoGL) {
+ const struct {
+ const char* gl_renderer;
+ const char* gl_vendor;
+ const char* gl_version;
+ const char* expected_driver_version;
+ } kTestStrings[] = {
+#if defined(OS_ANDROID)
+ {"Adreno (TM) 320",
+ "Qualcomm",
+ "OpenGL ES 2.0 V@14.0 AU@04.02 (CL@3206)",
+ "14.0"},
+ {"Adreno (TM) 420", "Qualcomm", "OpenGL ES 3.0 V@84.0 AU@ (CL@)", "84.0"},
+ {"PowerVR Rogue G6430",
+ "Imagination Technologies",
+ "OpenGL ES 3.1 build 1.4@3283119",
+ "1.4"},
+ {"Mali-T604", "ARM", "OpenGL ES 3.1", "0"},
+ {"NVIDIA Tegra",
+ "NVIDIA Corporation",
+ "OpenGL ES 3.1 NVIDIA 343.00",
+ "343.00"},
+ {"NVIDIA Tegra 3",
+ "NVIDIA Corporation",
+ "OpenGL ES 2.0 14.01003",
+ "14.01003"},
+ {"random GPU",
+ "random vendor",
+ "OpenGL ES 2.0 with_long_version_string=1.2.3.4",
+ "1.2"},
+ {"random GPU",
+ "random vendor",
+ "OpenGL ES 2.0 with_short_version_string=1",
+ "0"},
+ {"random GPU",
+ "random vendor",
+ "OpenGL ES 2.0 with_no_version_string",
+ "0"},
+#elif defined(OS_MACOSX)
+ {"Intel Iris Pro OpenGL Engine",
+ "Intel Inc.",
+ "2.1 INTEL-10.6.20",
+ "10.6.20"},
+#elif defined(OS_LINUX)
+ {"Quadro K2000/PCIe/SSE2",
+ "NVIDIA Corporation",
+ "4.4.0 NVIDIA 331.79",
+ "331.79"},
+#endif
+ {NULL, NULL, NULL, NULL}
+ };
+
+ GPUInfo gpu_info;
+ for (int i = 0; kTestStrings[i].gl_renderer != NULL; ++i) {
+ gpu_info.gl_renderer = kTestStrings[i].gl_renderer;
+ gpu_info.gl_vendor = kTestStrings[i].gl_vendor;
+ gpu_info.gl_version = kTestStrings[i].gl_version;
+ EXPECT_EQ(CollectDriverInfoGL(&gpu_info), kCollectInfoSuccess);
+ EXPECT_EQ(gpu_info.driver_version, kTestStrings[i].expected_driver_version);
+ }
+}
+
} // namespace gpu