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 name of Google Inc. 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.
31 from webkitpy.common.system.executive_mock import MockExecutive2
32 from webkitpy.common.system.filesystem_mock import MockFileSystem
33 from webkitpy.common.system.outputcapture import OutputCapture
34 from webkitpy.layout_tests.port.qt import QtPort
35 from webkitpy.layout_tests.port import port_testcase
36 from webkitpy.tool.mocktool import MockOptions
37 from webkitpy.common.system.executive_mock import MockExecutive
38 from webkitpy.common.host_mock import MockHost
41 class QtPortTest(port_testcase.PortTestCase):
44 def _assert_search_path(self, search_paths, sys_platform, use_webkit2=False, qt_version='4.7'):
45 # FIXME: Port constructors should not "parse" the port name, but
46 # rather be passed components (directly or via setters). Once
47 # we fix that, this method will need a re-write.
48 port = QtPort(sys_platform=sys_platform,
49 options=MockOptions(webkit_test_runner=use_webkit2, platform='qt'),
51 executive=MockExecutive2(self._qt_version(qt_version)))
52 absolute_search_paths = map(port._webkit_baseline_path, search_paths)
53 self.assertEquals(port.baseline_search_path(), absolute_search_paths)
55 def _qt_version(self, qt_version):
56 if qt_version in '4.7':
57 return 'QMake version 2.01a\nUsing Qt version 4.7.3 in /usr/local/Trolltech/Qt-4.7.3/lib'
58 if qt_version in '4.8':
59 return 'QMake version 2.01a\nUsing Qt version 4.8.0 in /usr/local/Trolltech/Qt-4.8.2/lib'
60 if qt_version in '5.0':
61 return 'QMake version 2.01a\nUsing Qt version 5.0.0 in /usr/local/Trolltech/Qt-5.0.0/lib'
63 def test_baseline_search_path(self):
64 self._assert_search_path(['qt-mac', 'qt-4.7', 'qt'], 'darwin')
65 self._assert_search_path(['qt-win', 'qt-4.7', 'qt'], 'win32')
66 self._assert_search_path(['qt-win', 'qt-4.7', 'qt'], 'cygwin')
67 self._assert_search_path(['qt-linux', 'qt-4.7', 'qt'], 'linux2')
68 self._assert_search_path(['qt-linux', 'qt-4.7', 'qt'], 'linux3')
70 self._assert_search_path(['qt-mac', 'qt-4.8', 'qt'], 'darwin', qt_version='4.8')
71 self._assert_search_path(['qt-win', 'qt-4.8', 'qt'], 'win32', qt_version='4.8')
72 self._assert_search_path(['qt-win', 'qt-4.8', 'qt'], 'cygwin', qt_version='4.8')
73 self._assert_search_path(['qt-linux', 'qt-4.8', 'qt'], 'linux2', qt_version='4.8')
74 self._assert_search_path(['qt-linux', 'qt-4.8', 'qt'], 'linux3', qt_version='4.8')
76 self._assert_search_path(['qt-wk2', 'qt-mac', 'qt-5.0', 'qt'], 'darwin', use_webkit2=True, qt_version='5.0')
77 self._assert_search_path(['qt-wk2', 'qt-win', 'qt-5.0', 'qt'], 'cygwin', use_webkit2=True, qt_version='5.0')
78 self._assert_search_path(['qt-wk2', 'qt-linux', 'qt-5.0', 'qt'], 'linux2', use_webkit2=True, qt_version='5.0')
80 def test_show_results_html_file(self):
81 port = self.make_port()
82 port._executive = MockExecutive(should_log=True)
83 expected_stderr = "MOCK run_command: ['Tools/Scripts/run-launcher', '--release', '--qt', 'file://test.html'], cwd=/mock-checkout\n"
84 OutputCapture().assert_outputs(self, port.show_results_html_file, ["test.html"], expected_stderr=expected_stderr)
86 def test_setup_environ_for_server(self):
87 port = self.make_port()
88 env = port.setup_environ_for_server(port.driver_name())
89 self.assertEquals(env['QTWEBKIT_PLUGIN_PATH'], 'MOCK output of child process/lib/plugins')