diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-25 23:04:27 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-25 23:04:27 +0000 |
commit | da4e34b86c37f77dc7027fbc1fd599d319b69bd0 (patch) | |
tree | 766bfa4861fc2f6b97701f32849c85dad16313ee | |
parent | 95ab1553ce02175cf23278d80b8440b27740159c (diff) | |
download | chromium_src-da4e34b86c37f77dc7027fbc1fd599d319b69bd0.zip chromium_src-da4e34b86c37f77dc7027fbc1fd599d319b69bd0.tar.gz chromium_src-da4e34b86c37f77dc7027fbc1fd599d319b69bd0.tar.bz2 |
Print a warning when running layout tests with incorrect theme.
Review URL: http://codereview.chromium.org/12631
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6005 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | webkit/tools/layout_tests/run_webkit_tests.py | 15 | ||||
-rw-r--r-- | webkit/tools/test_shell/mac/main.mm | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_main.cc | 64 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_switches.cc | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_switches.h | 1 |
5 files changed, 90 insertions, 1 deletions
diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py index 589fde6..28f4020 100755 --- a/webkit/tools/layout_tests/run_webkit_tests.py +++ b/webkit/tools/layout_tests/run_webkit_tests.py @@ -202,6 +202,17 @@ class TestRunner: if not self._test_files: return 0 start_time = time.time() + test_shell_binary = path_utils.TestShellBinaryPath(self._options.target) + + # Check that the system dependencies (themes, fonts, ...) are correct. + if not self._options.nocheck_sys_deps: + proc = subprocess.Popen([test_shell_binary, + "--check-layout-test-sys-deps"]) + if proc.wait() != 0: + logging.info("Aborting because system dependencies check failed.\n" + "To override, invoke with --nocheck-sys-deps") + sys.exit(1) + logging.info("Starting tests") # Create the output directory if it doesn't already exist. @@ -221,7 +232,6 @@ class TestRunner: # Instantiate TestShellThreads and start them. threads = [] - test_shell_binary = path_utils.TestShellBinaryPath(self._options.target) for i in xrange(int(self._options.num_test_shells)): shell_args = [] test_args = test_type_base.TestArguments() @@ -640,5 +650,8 @@ if '__main__' == __name__: option_parser.add_option("", "--test-list", action="append", help="read list of tests to run from file", metavar="FILE") + option_parser.add_option("", "--nocheck-sys-deps", action="store_true", + default=False, + help="Don't check the system dependencies (themes)") options, args = option_parser.parse_args() main(options, args) diff --git a/webkit/tools/test_shell/mac/main.mm b/webkit/tools/test_shell/mac/main.mm index 9dd39be..b3ccff5 100644 --- a/webkit/tools/test_shell/mac/main.mm +++ b/webkit/tools/test_shell/mac/main.mm @@ -114,6 +114,11 @@ int main(const int argc, const char *argv[]) { CommandLine::SetArgcArgv(argc, argv); CommandLine parsed_command_line(argc, argv); + if (parsed_command_line.HasSwitch(test_shell::kCheckLayoutTestSystemDeps)) { + // Always succeed the deps check, currently just used by windows port. + exit(0); + } + if (parsed_command_line.HasSwitch(test_shell::kStartupDialog)) { //TODO: add alert to allow attaching via gdb before things really get going } diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 42e16fb..f8bd0be 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -13,6 +13,7 @@ #include "base/event_recorder.h" #include "base/gfx/native_theme.h" #include "base/resource_util.h" +#include "base/win_util.h" #include "webkit/tools/test_shell/foreground_helper.h" #endif @@ -71,8 +72,67 @@ StringPiece GetRawDataResource(HMODULE module, int resource_id) { StringPiece NetResourceProvider(int key) { return GetRawDataResource(::GetModuleHandle(NULL), key); } + +// This test approximates whether you have the Windows XP theme selected by +// inspecting a couple of metrics. It does not catch all cases, but it does +// pick up on classic vs xp, and normal vs large fonts. Something it misses +// is changes to the color scheme (which will infact cause pixel test +// failures). +// +// ** Expected dependencies ** +// + Theme: Windows XP +// + Color scheme: Default (blue) +// + Font size: Normal +// + Font smoothing: off (minor impact). +// +bool HasLayoutTestThemeDependenciesWin() { + // This metric will be 17 when font size is "Normal". The size of drop-down + // menus depends on it. + if (::GetSystemMetrics(SM_CXVSCROLL) != 17) + return false; + + // Check that the system fonts RenderThemeWin relies on are Tahoma 11 pt. + NONCLIENTMETRICS metrics; + win_util::GetNonClientMetrics(&metrics); + LOGFONTW* system_fonts[] = + { &metrics.lfStatusFont, &metrics.lfMenuFont, &metrics.lfSmCaptionFont }; + + for (size_t i = 0; i < arraysize(system_fonts); ++i) { + if (system_fonts[i]->lfHeight != -11 || + 0 != wcscmp(L"Tahoma", system_fonts[i]->lfFaceName)) + return false; + } + return true; +} + +bool CheckLayoutTestSystemDependenciesWin() { + bool has_deps = HasLayoutTestThemeDependenciesWin(); + if (!has_deps) { + fprintf(stderr, + "\n" + "###############################################################\n" + "## Layout test system dependencies check failed.\n" + "## Some layout tests may fail due to unexpected theme.\n" + "##\n" + "## To fix, go to Display Properties -> Appearance, and select:\n" + "## + Windows and buttons: Windows XP style\n" + "## + Color scheme: Default (blue)\n" + "## + Font size: Normal\n" + "###############################################################\n"); + } + return has_deps; +} + #endif +bool CheckLayoutTestSystemDependencies() { +#if defined(OS_WIN) + return CheckLayoutTestSystemDependenciesWin(); +#else + return true; +#endif +} + } // namespace @@ -96,6 +156,10 @@ int main(int argc, char* argv[]) { if (parsed_command_line.HasSwitch(test_shell::kStartupDialog)) TestShell::ShowStartupDebuggingDialog(); + if (parsed_command_line.HasSwitch(test_shell::kCheckLayoutTestSystemDeps)) { + exit(CheckLayoutTestSystemDependencies() ? 0 : 1); + } + // Allocate a message loop for this thread. Although it is not used // directly, its constructor sets up some necessary state. MessageLoopForUI main_message_loop; diff --git a/webkit/tools/test_shell/test_shell_switches.cc b/webkit/tools/test_shell/test_shell_switches.cc index 9ee7e89..26b53e0 100644 --- a/webkit/tools/test_shell/test_shell_switches.cc +++ b/webkit/tools/test_shell/test_shell_switches.cc @@ -61,5 +61,11 @@ const wchar_t kEnableTracing[] = L"enable-tracing"; // Allow scripts to close windows in all cases. const wchar_t kAllowScriptsToCloseWindows[] = L"allow-scripts-to-close-windows"; +// Test the system dependencies (themes, fonts, ...). When this flag is +// specified, the test shell will exit immediately with either 0 (success) or +// 1 (failure). Combining with other flags has no effect. +extern const wchar_t kCheckLayoutTestSystemDeps[] = + L"check-layout-test-sys-deps"; + } // namespace test_shell diff --git a/webkit/tools/test_shell/test_shell_switches.h b/webkit/tools/test_shell/test_shell_switches.h index 83e08dc..450c5ee 100644 --- a/webkit/tools/test_shell/test_shell_switches.h +++ b/webkit/tools/test_shell/test_shell_switches.h @@ -28,6 +28,7 @@ extern const wchar_t kEnableFileCookies[]; extern const wchar_t kUseWinHttp[]; extern const wchar_t kEnableTracing[]; extern const wchar_t kAllowScriptsToCloseWindows[]; +extern const wchar_t kCheckLayoutTestSystemDeps[]; } // namespace test_shell |