diff options
author | dpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 20:45:48 +0000 |
---|---|---|
committer | dpranke@google.com <dpranke@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 20:45:48 +0000 |
commit | 6bbffad8e16f5845a4bdbbbc25440b4d30157438 (patch) | |
tree | 814b0cadab8346f61ea3be3eb664160022ce3f37 | |
parent | 5dbbc64204111ec3645b4c3e534601770b02242f (diff) | |
download | chromium_src-6bbffad8e16f5845a4bdbbbc25440b4d30157438.zip chromium_src-6bbffad8e16f5845a4bdbbbc25440b4d30157438.tar.gz chromium_src-6bbffad8e16f5845a4bdbbbc25440b4d30157438.tar.bz2 |
add layout_test_helper on windows
add layout_test_helper to toggle cleartype on and off as necessary for
layout tests on windows (mirroring similar functionality on the mac)
BUG=none
R=tony
TEST=none
Review URL: http://codereview.chromium.org/159684
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22185 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 90 insertions, 8 deletions
diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_linux.py b/webkit/tools/layout_tests/layout_package/platform_utils_linux.py index b496112..7d06054 100644 --- a/webkit/tools/layout_tests/layout_package/platform_utils_linux.py +++ b/webkit/tools/layout_tests/layout_package/platform_utils_linux.py @@ -172,6 +172,10 @@ class PlatformUtility(object): """Path to the image_diff binary.""" return PathFromBuildResults(target, 'image_diff') + def LayoutTestHelperPath(self, target): + """Path to the layout_test helper binary, if needed, empty otherwise""" + return '' + def TestShellBinary(self): """The name of the binary for TestShell.""" return 'test_shell' diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_mac.py b/webkit/tools/layout_tests/layout_package/platform_utils_mac.py index 0a79ba6..1aa19b0 100644 --- a/webkit/tools/layout_tests/layout_package/platform_utils_mac.py +++ b/webkit/tools/layout_tests/layout_package/platform_utils_mac.py @@ -158,6 +158,7 @@ class PlatformUtility(object): return PathFromBase('xcodebuild', target, 'image_diff') def LayoutTestHelperBinaryPath(self, target): + """Path to the layout_test helper binary, if needed, empty otherwise""" return PathFromBase('xcodebuild', target, 'layout_test_helper') def TestShellBinary(self): diff --git a/webkit/tools/layout_tests/layout_package/platform_utils_win.py b/webkit/tools/layout_tests/layout_package/platform_utils_win.py index 2ba299a..cb5b343 100644 --- a/webkit/tools/layout_tests/layout_package/platform_utils_win.py +++ b/webkit/tools/layout_tests/layout_package/platform_utils_win.py @@ -188,6 +188,10 @@ class PlatformUtility(google.platform_utils_win.PlatformUtility): def ImageCompareExecutablePath(self, target): return PathFromBase('chrome', target, 'image_diff.exe') + def LayoutTestHelperBinaryPath(self, target): + """Path to the layout_test helper binary, if needed, empty otherwise""" + return PathFromBase('chrome', target, 'layout_test_helper.exe') + def TestShellBinary(self): """The name of the binary for TestShell.""" return 'test_shell.exe' diff --git a/webkit/tools/layout_tests/run_webkit_tests.py b/webkit/tools/layout_tests/run_webkit_tests.py index a209bdb..65b719e 100755 --- a/webkit/tools/layout_tests/run_webkit_tests.py +++ b/webkit/tools/layout_tests/run_webkit_tests.py @@ -514,11 +514,9 @@ class TestRunner: # Start up any helper needed layout_test_helper_proc = None - if sys.platform in ('darwin'): - # Mac uses a helper for manging the color sync profile for pixel tests. - if not options.no_pixel_tests: - helper_path = \ - path_utils.LayoutTestHelperBinaryPath(self._options.target) + if not options.no_pixel_tests: + helper_path = path_utils.LayoutTestHelperBinaryPath(self._options.target) + if len(helper_path): logging.info("Starting layout helper %s" % helper_path) layout_test_helper_proc = subprocess.Popen([helper_path], stdin=subprocess.PIPE, diff --git a/webkit/tools/test_shell/test_shell.gyp b/webkit/tools/test_shell/test_shell.gyp index 330bb01..9c17de5 100644 --- a/webkit/tools/test_shell/test_shell.gyp +++ b/webkit/tools/test_shell/test_shell.gyp @@ -208,7 +208,7 @@ }, 'conditions': [ ['OS=="win"', { - 'dependencies': ['test_worker'], + 'dependencies': ['test_worker', 'layout_test_helper'], 'resource_include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)/webkit', ], @@ -628,7 +628,20 @@ }, ], }], - ['OS=="mac"', { + ['OS=="win"', { + 'targets': [ + { + # Helper application that manages the color sync profile on mac + # for the test shells run by the layout tests. + 'target_name': 'layout_test_helper', + 'type': 'executable', + 'sources': [ + 'win/layout_test_helper.cc', + ], + }, + ], + }], + ['OS=="mac"', { 'targets': [ { # Helper application that manages the color sync profile on mac @@ -644,7 +657,7 @@ ], }, }, - ] + ], }], ], } diff --git a/webkit/tools/test_shell/win/layout_test_helper.cc b/webkit/tools/test_shell/win/layout_test_helper.cc new file mode 100644 index 0000000..b9bf0eb --- /dev/null +++ b/webkit/tools/test_shell/win/layout_test_helper.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2009 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. +// +// This is a simple helper app that disables Cleartype and does whatever +// else it can to get the system into the configuration the layout tests +// expect. + +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <windows.h> + +BOOL g_font_smoothing_enabled = FALSE; + +static void SaveInitialSettings(void) { + BOOL ret; + ret = SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, + (PVOID)&g_font_smoothing_enabled, 0); +} + +// Technically, all we need to do is disable ClearType. However, +// for some reason, the call to SPI_SETFONTSMOOTHINGTYPE doesn't +// seem to work, so we just disable font smoothing all together +// (which works reliably) +static void InstallLayoutTestSettings(void) { + BOOL ret; + ret = SystemParametersInfo(SPI_SETFONTSMOOTHING, (UINT)FALSE, (PVOID)0, 0); +} + +static void RestoreInitialSettings(void) { + BOOL ret; + ret = SystemParametersInfo(SPI_SETFONTSMOOTHING, + (UINT)g_font_smoothing_enabled, (PVOID)0, 0); +} + +static void SimpleSignalHandler(int sig) { + // Try to restore the settings and then go down cleanly + RestoreInitialSettings(); + exit(128 + sig); +} + +int main(int argc, char *argv[]) { + // Hooks the ways we might get told to clean up... + signal(SIGINT, SimpleSignalHandler); + signal(SIGTERM, SimpleSignalHandler); + + SaveInitialSettings(); + + InstallLayoutTestSettings(); + + // Let the script know we're ready + printf("ready\n"); + fflush(stdout); + + // Wait for any key (or signal) + getchar(); + + RestoreInitialSettings(); + + return 0; +} |