diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 19:42:56 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 19:42:56 +0000 |
commit | aefbf90a3d90cde03bd2f244a477084f276b6540 (patch) | |
tree | 2c0b2513ab5c5040d49ff5e226671d58c892a8d0 | |
parent | eadc9679d5b47b498877d074efdc0ca913bd09b8 (diff) | |
download | chromium_src-aefbf90a3d90cde03bd2f244a477084f276b6540.zip chromium_src-aefbf90a3d90cde03bd2f244a477084f276b6540.tar.gz chromium_src-aefbf90a3d90cde03bd2f244a477084f276b6540.tar.bz2 |
ui_tests run with --use-gl=osmesa so they use the OSMesa software renderer for GL.
This to ensure that ui_tests run consistently regardless of the GPU capabilities, or absense, of the box they run on.
TEST=try
BUG=none
Review URL: http://codereview.chromium.org/4138003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64122 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | app/gfx/gl/gl_implementation.cc | 14 | ||||
-rw-r--r-- | app/gfx/gl/gl_implementation.h | 6 | ||||
-rw-r--r-- | chrome/chrome_exe.gypi | 37 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 4 | ||||
-rw-r--r-- | chrome/test/data/gpu/webgl.html | 54 | ||||
-rw-r--r-- | chrome/test/test_launcher_utils.cc | 9 | ||||
-rw-r--r-- | chrome/test/ui/gpu_uitest.cc | 39 | ||||
-rw-r--r-- | third_party/mesa/mesa.gyp | 5 |
8 files changed, 137 insertions, 31 deletions
diff --git a/app/gfx/gl/gl_implementation.cc b/app/gfx/gl/gl_implementation.cc index 21a4455..2a83cd2 100644 --- a/app/gfx/gl/gl_implementation.cc +++ b/app/gfx/gl/gl_implementation.cc @@ -13,6 +13,12 @@ #include "base/logging.h" namespace gfx { + +const char kGLImplementationDesktopName[] = "desktop"; +const char kGLImplementationOSMesaName[] = "osmesa"; +const char kGLImplementationEGLName[] = "egl"; +const char kGLImplementationMockName[] = "mock"; + namespace { typedef std::vector<base::NativeLibrary> LibraryArray; @@ -38,10 +44,10 @@ GLImplementation GetNamedGLImplementation(const std::string& name) { const char* name; GLImplementation implemention; } name_pairs[] = { - { "desktop", kGLImplementationDesktopGL }, - { "osmesa", kGLImplementationOSMesaGL }, - { "egl", kGLImplementationEGLGLES2 }, - { "mock", kGLImplementationMockGL } + { kGLImplementationDesktopName, kGLImplementationDesktopGL }, + { kGLImplementationOSMesaName, kGLImplementationOSMesaGL }, + { kGLImplementationEGLName, kGLImplementationEGLGLES2 }, + { kGLImplementationMockName, kGLImplementationMockGL } }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(name_pairs); ++i) { diff --git a/app/gfx/gl/gl_implementation.h b/app/gfx/gl/gl_implementation.h index 1b016b4..91dd617 100644 --- a/app/gfx/gl/gl_implementation.h +++ b/app/gfx/gl/gl_implementation.h @@ -22,6 +22,12 @@ enum GLImplementation { kGLImplementationMockGL }; +// The GL implementation names that can be passed to --use-gl. +extern const char kGLImplementationDesktopName[]; +extern const char kGLImplementationOSMesaName[]; +extern const char kGLImplementationEGLName[]; +extern const char kGLImplementationMockName[]; + #if defined(OS_WIN) typedef void* (WINAPI *GLGetProcAddressProc)(const char* name); #else diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index ebea4b5..29da686 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -459,29 +459,24 @@ }], ], }, + { + 'target_name': 'chrome_mesa', + 'type': 'none', + 'dependencies': [ + 'chrome', + '../third_party/mesa/mesa.gyp:osmesa', + ], + 'conditions': [ + ['OS=="mac"', { + 'copies': [{ + 'destination': '<(PRODUCT_DIR)/<(branding).app/Contents/Versions/<(version_full)/<(branding) Helper.app/Contents/MacOS/', + 'files': ['<(PRODUCT_DIR)/osmesa.so'], + }], + }], + ], + }, ], 'conditions': [ - # http://code.google.com/p/chromium/issues/detail?id=18337 - ['target_arch!="x64" and target_arch!="arm"', { - 'targets': [ - { - 'target_name': 'chrome_mesa', - 'type': 'none', - 'dependencies': [ - 'chrome', - '../third_party/mesa/mesa.gyp:osmesa', - ], - 'conditions': [ - ['OS=="mac"', { - 'copies': [{ - 'destination': '<(PRODUCT_DIR)/<(branding).app/Contents/Versions/<(version_full)/<(branding) Helper.app/Contents/MacOS/', - 'files': ['<(PRODUCT_DIR)/osmesa.so'], - }], - }], - ], - }, - ], - }], ['OS=="win"', { 'targets': [ { diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 7c6c46e..bd5e557 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -444,6 +444,7 @@ 'chrome_strings', 'profile_import', 'test_support_ui', + '../app/app.gyp:app_base', '../base/base.gyp:base', '../net/net.gyp:net', '../net/net.gyp:net_test_support', @@ -506,6 +507,7 @@ 'test/chrome_process_util_uitest.cc', 'test/ui/dom_checker_uitest.cc', 'test/ui/dromaeo_benchmark_uitest.cc', + 'test/ui/gpu_uitest.cc', 'test/ui/history_uitest.cc', 'test/ui/layout_plugin_uitest.cc', 'test/ui/npapi_uitest.cc', @@ -521,8 +523,8 @@ # http://code.google.com/p/chromium/issues/detail?id=18337 ['target_arch!="x64" and target_arch!="arm"', { 'dependencies': [ + 'chrome_mesa', '../webkit/webkit.gyp:copy_npapi_test_plugin', - '../third_party/mesa/mesa.gyp:osmesa', ], }], # Only copy the pepper plugin on Windows which is the only platform diff --git a/chrome/test/data/gpu/webgl.html b/chrome/test/data/gpu/webgl.html new file mode 100644 index 0000000..d070e48 --- /dev/null +++ b/chrome/test/data/gpu/webgl.html @@ -0,0 +1,54 @@ +<html> +<head> +<script type="text/javascript"> +var canvas; +var gl; + +function testHorizontalBands() { + gl.enable(gl.SCISSOR_TEST); + + gl.clearColor(1, 0, 0, 1); + gl.scissor(0, 0, 16, 16); + gl.clear(gl.COLOR_BUFFER_BIT); + + gl.clearColor(0, 1, 0, 1); + gl.scissor(0, 16, 16, 16); + gl.clear(gl.COLOR_BUFFER_BIT); + + gl.disable(gl.SCISSOR_TEST); + + var array = new Uint8Array(16 * 32 * 4); + gl.readPixels(0, 0, 16, 32, gl.RGBA, gl.UNSIGNED_BYTE, array); + + return array[0] == 255 && array[1] == 0 && + array[16 * 32 * 4 - 4] == 0 && array[16 * 32 * 4 - 3] == 255; +} + +function onLoad() { + canvas = document.getElementById("canvas1"); + if (!canvas) { + document.title = "FAILED: canvas element not found"; + return; + } + + gl = canvas.getContext("experimental-webgl"); + if (!gl) { + document.title = "FAILED: could not get webgl context for canvas"; + return; + } + + if (!testHorizontalBands()) { + document.title = "FAILED: did not render correctly"; + return; + } + + var renderer = gl.getParameter(gl.RENDERER); + document.title = "SUCCESS: " + renderer; +} +</script> +</head> +<body onload="onLoad()"> +<canvas id="canvas1" width="16px" height="32px"> +</canvas> +</body> +</html> diff --git a/chrome/test/test_launcher_utils.cc b/chrome/test/test_launcher_utils.cc index 59328e2..5b93422 100644 --- a/chrome/test/test_launcher_utils.cc +++ b/chrome/test/test_launcher_utils.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "app/app_switches.h" +#include "app/gfx/gl/gl_implementation.h" #include "base/command_line.h" #include "base/environment.h" #include "base/path_service.h" @@ -30,6 +32,13 @@ void PrepareBrowserCommandLineForTests(CommandLine* command_line) { // Enable warning level logging so that we can see when bad stuff happens. command_line->AppendSwitch(switches::kEnableLogging); command_line->AppendSwitchASCII(switches::kLoggingLevel, "1"); // warning + + // TODO(apatrick): Other pending changes will fix this for mac. +#if !defined(OS_MACOSX) + // Force all tests to use OSMesa if they launch the GPU process. + command_line->AppendSwitchASCII(switches::kUseGL, + gfx::kGLImplementationOSMesaName); +#endif } bool OverrideUserDataDir(const FilePath& user_data_dir) { diff --git a/chrome/test/ui/gpu_uitest.cc b/chrome/test/ui/gpu_uitest.cc new file mode 100644 index 0000000..75a6f5a --- /dev/null +++ b/chrome/test/ui/gpu_uitest.cc @@ -0,0 +1,39 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <string> + +#include "build/build_config.h" +#include "chrome/test/ui/ui_test.h" +#include "net/base/net_util.h" + +class GPUTest : public UITest { + protected: + GPUTest() { + } + + virtual void SetUp() { + UITest::SetUp(); + gpu_test_dir_ = test_data_directory_.AppendASCII("gpu"); + } + + FilePath gpu_test_dir_; +}; + +// TODO(apatrick): Other pending changes will fix this for mac. +#if defined(OS_MACOSX) +#define MAYBE_UITestLaunchedWithOSMesa FAILS_UITestLaunchedWithOSMesa +#else +#define MAYBE_UITestLaunchedWithOSMesa UITestLaunchedWithOSMesa +#endif + +TEST_F(GPUTest, MAYBE_UITestLaunchedWithOSMesa) { + // Check the webgl test reports success and that the renderer was OSMesa. + // We use OSMesa for tests in order to get consistent results across a + // variety of boxes. + NavigateToURL( + net::FilePathToFileURL(gpu_test_dir_.AppendASCII("webgl.html"))); + + EXPECT_EQ(std::wstring(L"SUCCESS: Mesa OffScreen"), GetActiveTabTitle()); +} diff --git a/third_party/mesa/mesa.gyp b/third_party/mesa/mesa.gyp index c37196f..3725736 100644 --- a/third_party/mesa/mesa.gyp +++ b/third_party/mesa/mesa.gyp @@ -7,11 +7,6 @@ }, 'target_defaults': { 'conditions': [ - ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', { - 'cflags': [ - '-fPIC', - ], - }], ['OS!="win"', { 'defines': [ # For talloc |