2 # Copyright (C) 2010 Google Inc. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
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
14 # * Neither the Google name 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.
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.
30 """Dummy Port implementation used for testing."""
38 class TestPort(base.Port):
39 """Test implementation of the Port interface."""
41 def __init__(self, port_name=None, options=None):
42 base.Port.__init__(self, port_name, options)
44 def base_platforms(self):
47 def baseline_path(self):
48 curdir = os.path.abspath(__file__)
49 self.topdir = curdir[0:curdir.index("WebKitTools")]
50 return os.path.join(self.topdir, 'LayoutTests', 'platform', 'test')
52 def baseline_search_path(self):
53 return [self.baseline_path()]
55 def check_sys_deps(self):
58 def diff_image(self, actual_filename, expected_filename, diff_filename):
61 def compare_text(self, actual_text, expected_text):
64 def diff_text(self, actual_text, expected_text,
65 actual_filename, expected_filename):
72 return int(os.popen2("sysctl -n hw.ncpu")[1].read())
77 def results_directory(self):
78 return '/tmp' + self._options.results_directory
80 def setup_test_run(self):
83 def show_results_html_file(self, filename):
86 def start_driver(self, image_path, options):
87 return TestDriver(image_path, options, self)
89 def start_http_server(self):
92 def start_websocket_server(self):
95 def start_helper(self):
98 def stop_http_server(self):
101 def stop_websocket_server(self):
104 def stop_helper(self):
107 def test_expectations(self):
110 def test_base_platform_names(self):
113 def test_platform_name(self):
116 def test_platform_names(self):
117 return self.test_base_platform_names()
122 def wdiff_text(self, actual_filename, expected_filename):
126 class TestDriver(base.Driver):
127 """Test/Dummy implementation of the DumpRenderTree interface."""
129 def __init__(self, image_path, test_driver_options, port):
130 self._driver_options = test_driver_options
131 self._image_path = image_path
137 def returncode(self):
140 def run_test(self, uri, timeoutms, image_hash):
141 return (False, False, image_hash, '', None)