1 # Copyright (C) 2010 Google Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
13 # * Neither the Google name nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 """QtWebKit implementation of the Port interface."""
37 from webkitpy.common.memoized import memoized
38 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
39 from webkitpy.layout_tests.port.webkit import WebKitPort
42 _log = logging.getLogger(__name__)
45 class QtPort(WebKitPort):
46 ALL_VERSIONS = ['linux', 'win', 'mac']
49 def _port_flag_for_scripts(self):
52 def _operating_system_for_platform(self, platform):
53 if platform.startswith('linux'):
55 elif platform in ('win32', 'cygwin'):
57 elif platform == 'darwin':
61 # sys_platform exists only for unit testing.
62 def __init__(self, host, port_name=None, sys_platform=None, **kwargs):
63 port_name = port_name or self.port_name
64 WebKitPort.__init__(self, host, port_name=None, **kwargs)
65 self._operating_system = self._operating_system_for_platform(sys_platform or sys.platform)
66 self._version = self._operating_system
68 # FIXME: This will allow WebKitPort.baseline_search_path and WebKitPort._skipped_file_search_paths
69 # to do the right thing, but doesn't include support for qt-4.8 or qt-arm (seen in LayoutTests/platform) yet.
71 if port_name != self.port_name:
72 self._name = port_name
74 name_components = [self.port_name]
75 if self._operating_system:
76 name_components.append(self._operating_system)
77 self._name = "-".join(name_components)
79 def _generate_all_test_configurations(self):
81 for version in self.ALL_VERSIONS:
82 for build_type in self.ALL_BUILD_TYPES:
83 configurations.append(TestConfiguration(version=version, architecture='x86', build_type=build_type, graphics_type='cpu'))
86 def _build_driver(self):
87 # The Qt port builds DRT as part of the main build step
90 def _path_to_driver(self):
91 return self._build_path('bin/%s' % self.driver_name())
93 def _path_to_image_diff(self):
94 return self._build_path('bin/ImageDiff')
96 def _path_to_webcore_library(self):
97 if self._operating_system == 'mac':
98 return self._build_path('lib/QtWebKit.framework/QtWebKit')
100 return self._build_path('lib/libQtWebKit.so')
103 def qt_version(self):
106 for line in self._executive.run_command(['qmake', '-v']).split('\n'):
107 match = re.search('Qt\sversion\s(?P<version>\d\.\d)', line)
109 version = match.group('version')
115 def baseline_search_path(self):
117 if self.get_option('webkit_test_runner'):
118 search_paths.append(self._wk2_port_name())
119 search_paths.append(self.name())
120 version = self.qt_version()
122 search_paths.append('qt-4.7')
123 elif '4.8' in version:
124 search_paths.append('qt-4.8')
126 search_paths.append('qt-5.0')
127 search_paths.append(self.port_name)
128 return map(self._webkit_baseline_path, search_paths)
130 def _skipped_file_search_paths(self):
131 search_paths = set([self.port_name, self.name()])
132 version = self.qt_version()
134 search_paths.add('qt-4.7')
135 elif '4.8' in version:
136 search_paths.add('qt-4.8')
138 search_paths.add('qt-5.0')
139 if self.get_option('webkit_test_runner'):
140 search_paths.update(['qt-wk2', 'wk2'])
142 search_paths.add('qt-wk1')
145 def _runtime_feature_list(self):
148 def setup_environ_for_server(self, server_name=None):
149 clean_env = WebKitPort.setup_environ_for_server(self, server_name)
150 clean_env['QTWEBKIT_PLUGIN_PATH'] = self._build_path('lib/plugins')
151 self._copy_value_from_environ_if_set(clean_env, 'QT_DRT_WEBVIEW_MODE')
154 # FIXME: We should find a way to share this implmentation with Gtk,
155 # or teach run-launcher how to call run-safari and move this down to WebKitPort.
156 def show_results_html_file(self, results_filename):
157 run_launcher_args = []
158 if self.get_option('webkit_test_runner'):
159 run_launcher_args.append('-2')
160 run_launcher_args.append("file://%s" % results_filename)
161 self._run_script("run-launcher", run_launcher_args)