Clean up ChunkedUpdateDrawingAreaProxy
[WebKit-https.git] / WebKitTools / Scripts / webkitpy / layout_tests / port / chromium_win.py
1 #!/usr/bin/env python
2 # Copyright (C) 2010 Google Inc. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 #     * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 #     * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 #     * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 """Chromium Win implementation of the Port interface."""
31
32 import logging
33 import os
34 import sys
35
36 import chromium
37
38 _log = logging.getLogger("webkitpy.layout_tests.port.chromium_win")
39
40
41 class ChromiumWinPort(chromium.ChromiumPort):
42     """Chromium Win implementation of the Port class."""
43
44     def __init__(self, **kwargs):
45         kwargs.setdefault('port_name', 'chromium-win' + self.version())
46         chromium.ChromiumPort.__init__(self, **kwargs)
47
48     def setup_environ_for_server(self):
49         env = chromium.ChromiumPort.setup_environ_for_server(self)
50         # Put the cygwin directory first in the path to find cygwin1.dll.
51         env["PATH"] = "%s;%s" % (
52             self.path_from_chromium_base("third_party", "cygwin", "bin"),
53             env["PATH"])
54         # Configure the cygwin directory so that pywebsocket finds proper
55         # python executable to run cgi program.
56         env["CYGWIN_PATH"] = self.path_from_chromium_base(
57             "third_party", "cygwin", "bin")
58         if (sys.platform == "win32" and self.get_option('register_cygwin')):
59             setup_mount = self.path_from_chromium_base("third_party",
60                                                        "cygwin",
61                                                        "setup_mount.bat")
62             self._executive.run_command([setup_mount])
63         return env
64
65     def baseline_search_path(self):
66         port_names = []
67         if self._name.endswith('-win-xp'):
68             port_names.append("chromium-win-xp")
69         if self._name.endswith('-win-xp') or self._name.endswith('-win-vista'):
70             port_names.append("chromium-win-vista")
71         # FIXME: This may need to include mac-snowleopard like win.py.
72         port_names.extend(["chromium-win", "chromium", "win", "mac"])
73         return map(self._webkit_baseline_path, port_names)
74
75     def check_build(self, needs_http):
76         result = chromium.ChromiumPort.check_build(self, needs_http)
77         if not result:
78             _log.error('For complete Windows build requirements, please '
79                        'see:')
80             _log.error('')
81             _log.error('    http://dev.chromium.org/developers/how-tos/'
82                        'build-instructions-windows')
83         return result
84
85     def relative_test_filename(self, filename):
86         path = filename[len(self.layout_tests_dir()) + 1:]
87         return path.replace('\\', '/')
88
89     def test_platform_name(self):
90         # We return 'win-xp', not 'chromium-win-xp' here, for convenience.
91         return 'win' + self.version()
92
93     def version(self):
94         if not hasattr(sys, 'getwindowsversion'):
95             return ''
96         winver = sys.getwindowsversion()
97         if winver[0] == 6 and (winver[1] == 1):
98             return '-7'
99         if winver[0] == 6 and (winver[1] == 0):
100             return '-vista'
101         if winver[0] == 5 and (winver[1] == 1 or winver[1] == 2):
102             return '-xp'
103         return ''
104
105     #
106     # PROTECTED ROUTINES
107     #
108     def _build_path(self, *comps):
109         p = self.path_from_chromium_base('webkit', *comps)
110         if os.path.exists(p):
111             return p
112         p = self.path_from_chromium_base('chrome', *comps)
113         if os.path.exists(p) or self.get_option('use_test_shell'):
114             return p
115         return os.path.join(self.path_from_webkit_base(), 'WebKit', 'chromium',
116                             *comps)
117
118     def _lighttpd_path(self, *comps):
119         return self.path_from_chromium_base('third_party', 'lighttpd', 'win',
120                                             *comps)
121
122     def _path_to_apache(self):
123         return self.path_from_chromium_base('third_party', 'cygwin', 'usr',
124                                             'sbin', 'httpd')
125
126     def _path_to_apache_config_file(self):
127         return os.path.join(self.layout_tests_dir(), 'http', 'conf',
128                             'cygwin-httpd.conf')
129
130     def _path_to_lighttpd(self):
131         return self._lighttpd_path('LightTPD.exe')
132
133     def _path_to_lighttpd_modules(self):
134         return self._lighttpd_path('lib')
135
136     def _path_to_lighttpd_php(self):
137         return self._lighttpd_path('php5', 'php-cgi.exe')
138
139     def _path_to_driver(self, configuration=None):
140         if not configuration:
141             configuration = self.get_option('configuration')
142         binary_name = 'DumpRenderTree.exe'
143         if self.get_option('use_test_shell'):
144             binary_name = 'test_shell.exe'
145         return self._build_path(configuration, binary_name)
146
147     def _path_to_helper(self):
148         binary_name = 'LayoutTestHelper.exe'
149         if self.get_option('use_test_shell'):
150             binary_name = 'layout_test_helper.exe'
151         return self._build_path(self.get_option('configuration'), binary_name)
152
153     def _path_to_image_diff(self):
154         binary_name = 'ImageDiff.exe'
155         if self.get_option('use_test_shell'):
156             binary_name = 'image_diff.exe'
157         return self._build_path(self.get_option('configuration'), binary_name)
158
159     def _path_to_wdiff(self):
160         return self.path_from_chromium_base('third_party', 'cygwin', 'bin',
161                                             'wdiff.exe')
162
163     def _shut_down_http_server(self, server_pid):
164         """Shut down the lighttpd web server. Blocks until it's fully
165         shut down.
166
167         Args:
168             server_pid: The process ID of the running server.
169         """
170         # FIXME: Why are we ignoring server_pid and calling
171         # _kill_all instead of Executive.kill_process(pid)?
172         self._executive.kill_all("LightTPD.exe")
173         self._executive.kill_all("httpd.exe")