1dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# Copyright (C) 2010 Google Inc. All rights reserved. 2dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# 3dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# Redistribution and use in source and binary forms, with or without 4dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# modification, are permitted provided that the following conditions are 5dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# met: 6dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# 7dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# * Redistributions of source code must retain the above copyright 8dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# notice, this list of conditions and the following disclaimer. 9dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# * Redistributions in binary form must reproduce the above 10dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# copyright notice, this list of conditions and the following disclaimer 11dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# in the documentation and/or other materials provided with the 12dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# distribution. 13dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# * Neither the Google name nor the names of its 14dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# contributors may be used to endorse or promote products derived from 15dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# this software without specific prior written permission. 16dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# 17dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 29dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block"""QtWebKit implementation of the Port interface.""" 30dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 31dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockimport logging 32dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockimport os 33dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockimport signal 34e14391e94c850b8bd03680c23b38978db68687a8John Reckimport sys 35dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 36e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarkeimport webkit 37e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 38dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockfrom webkitpy.layout_tests.port.webkit import WebKitPort 39dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 40dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block_log = logging.getLogger("webkitpy.layout_tests.port.qt") 41dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 42dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 43dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockclass QtPort(WebKitPort): 44dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block """QtWebKit implementation of the Port class.""" 45dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 46bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen def __init__(self, **kwargs): 47bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen kwargs.setdefault('port_name', 'qt') 48bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen WebKitPort.__init__(self, **kwargs) 49dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 50e14391e94c850b8bd03680c23b38978db68687a8John Reck def baseline_search_path(self): 51e14391e94c850b8bd03680c23b38978db68687a8John Reck port_names = [] 52e14391e94c850b8bd03680c23b38978db68687a8John Reck if sys.platform == 'linux2': 53e14391e94c850b8bd03680c23b38978db68687a8John Reck port_names.append("qt-linux") 54e14391e94c850b8bd03680c23b38978db68687a8John Reck elif sys.platform in ('win32', 'cygwin'): 55e14391e94c850b8bd03680c23b38978db68687a8John Reck port_names.append("qt-win") 56e14391e94c850b8bd03680c23b38978db68687a8John Reck elif sys.platform == 'darwin': 57e14391e94c850b8bd03680c23b38978db68687a8John Reck port_names.append("qt-mac") 58e14391e94c850b8bd03680c23b38978db68687a8John Reck port_names.append("qt") 59e14391e94c850b8bd03680c23b38978db68687a8John Reck return map(self._webkit_baseline_path, port_names) 60e14391e94c850b8bd03680c23b38978db68687a8John Reck 61dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block def _tests_for_other_platforms(self): 62dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # FIXME: This list could be dynamic based on platform name and 63dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # pushed into base.Port. 64dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # This really need to be automated. 65dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block return [ 66dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block "platform/chromium", 67dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block "platform/win", 68dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block "platform/gtk", 69dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block "platform/mac", 70dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block ] 71dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 72dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block def _path_to_apache_config_file(self): 73dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # FIXME: This needs to detect the distribution and change config files. 74ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 75ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdoch 'apache2-debian-httpd.conf') 76dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 77dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block def _shut_down_http_server(self, server_pid): 78dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block """Shut down the httpd web server. Blocks until it's fully 79dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block shut down. 80dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 81dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block Args: 82dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block server_pid: The process ID of the running server. 83dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block """ 84dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # server_pid is not set when "http_server.py stop" is run manually. 85dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block if server_pid is None: 86dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # FIXME: This isn't ideal, since it could conflict with 87dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # lighttpd processes not started by http_server.py, 88dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # but good enough for now. 8921939df44de1705786c545cd1bf519d47250322dBen Murdoch self._executive.kill_all('apache2') 90dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block else: 91dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block try: 92dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block os.kill(server_pid, signal.SIGTERM) 93dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # TODO(mmoss) Maybe throw in a SIGKILL just to be sure? 94dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block except OSError: 95dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # Sometimes we get a bad PID (e.g. from a stale httpd.pid 96dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # file), so if kill fails on the given PID, just try to 97dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # 'killall' web servers. 98dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block self._shut_down_http_server(None) 99dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 100dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block def _build_driver(self): 101dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block # The Qt port builds DRT as part of the main build step 102dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block return True 103dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 104dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block def _path_to_driver(self): 105dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block return self._build_path('bin/DumpRenderTree') 106e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke 107e14391e94c850b8bd03680c23b38978db68687a8John Reck def _path_to_image_diff(self): 108e14391e94c850b8bd03680c23b38978db68687a8John Reck return self._build_path('bin/ImageDiff') 109e14391e94c850b8bd03680c23b38978db68687a8John Reck 1105abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick def _path_to_webcore_library(self): 1115abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick return self._build_path('lib/libQtWebKit.so') 1125abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 1135abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick def _runtime_feature_list(self): 1145abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick return None 1155abb8606fa57c3ebfc8b3c3dbc3fa4a25d2ae306Iain Merrick 116e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke def setup_environ_for_server(self): 11781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch env = WebKitPort.setup_environ_for_server(self) 118e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke env['QTWEBKIT_PLUGIN_PATH'] = self._build_path('lib/plugins') 119e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke return env 120