OSDN Git Service

am b7c854ae: am 18e97e57: merge from open-source master
[android-x86/external-webkit.git] / WebKitTools / Scripts / webkitpy / layout_tests / port / test.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 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.
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 """Dummy Port implementation used for testing."""
31
32 import os
33 import time
34
35 import base
36
37
38 class TestPort(base.Port):
39     """Test implementation of the Port interface."""
40
41     def __init__(self, port_name=None, options=None):
42         base.Port.__init__(self, port_name, options)
43
44     def base_platforms(self):
45         return ('test',)
46
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')
51
52     def baseline_search_path(self):
53         return [self.baseline_path()]
54
55     def check_build(self, needs_http):
56         return True
57
58     def compare_text(self, expected_text, actual_text):
59         return False
60
61     def diff_image(self, expected_filename, actual_filename,
62                    diff_filename=None):
63         return False
64
65     def diff_text(self, expected_text, actual_text,
66                   expected_filename, actual_filename):
67         return ''
68
69     def relative_test_filename(self, filename):
70         return filename
71
72     def expected_filename(self, filename, suffix):
73         (basename, ext) = os.path.splitext(filename)
74         return basename + '.' + suffix
75
76     def name(self):
77         return self._name
78
79     def options(self):
80         return self._options
81
82     def results_directory(self):
83         return '/tmp/' + self._options.results_directory
84
85     def setup_test_run(self):
86         pass
87
88     def show_results_html_file(self, filename):
89         pass
90
91     def create_driver(self, image_path, options):
92         return TestDriver(image_path, options, self)
93
94     def start_http_server(self):
95         pass
96
97     def start_websocket_server(self):
98         pass
99
100     def stop_http_server(self):
101         pass
102
103     def stop_websocket_server(self):
104         pass
105
106     def test_expectations(self):
107         return ''
108
109     def test_base_platform_names(self):
110         return ('test',)
111
112     def test_platform_name(self):
113         return 'test'
114
115     def test_platform_names(self):
116         return self.test_base_platform_names()
117
118     def version():
119         return ''
120
121     def wdiff_text(self, expected_filename, actual_filename):
122         return ''
123
124
125 class TestDriver(base.Driver):
126     """Test/Dummy implementation of the DumpRenderTree interface."""
127
128     def __init__(self, image_path, test_driver_options, port):
129         self._driver_options = test_driver_options
130         self._image_path = image_path
131         self._port = port
132
133     def poll(self):
134         return True
135
136     def returncode(self):
137         return 0
138
139     def run_test(self, uri, timeoutms, image_hash):
140         return (False, False, image_hash, '', None)
141
142     def start(self):
143         pass
144
145     def stop(self):
146         pass