Index: Tools/Scripts/webkitpy/layout_tests/port/browser_test.py |
diff --git a/Tools/Scripts/webkitpy/layout_tests/port/browser_test.py b/Tools/Scripts/webkitpy/layout_tests/port/browser_test.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c5e0ddc0b5e31a022ea9d1d96e746b89114b1b9a |
--- /dev/null |
+++ b/Tools/Scripts/webkitpy/layout_tests/port/browser_test.py |
@@ -0,0 +1,119 @@ |
+# Copyright (C) 2014 Google Inc. All rights reserved. |
+# |
+# Redistribution and use in source and binary forms, with or without |
+# modification, are permitted provided that the following conditions are |
+# met: |
+# |
+# * Redistributions of source code must retain the above copyright |
+# notice, this list of conditions and the following disclaimer. |
+# * Redistributions in binary form must reproduce the above |
+# copyright notice, this list of conditions and the following disclaimer |
+# in the documentation and/or other materials provided with the |
+# distribution. |
+# * Neither the Google name nor the names of its |
+# contributors may be used to endorse or promote products derived from |
+# this software without specific prior written permission. |
+# |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ |
+from webkitpy.layout_tests.port import base |
+from webkitpy.layout_tests.port import linux |
+from webkitpy.layout_tests.port import mac |
+from webkitpy.layout_tests.port import win |
+from webkitpy.layout_tests.port import browser_test_driver |
+ |
+ |
+class BrowserTestPortOverrides(base.Port): |
+ """Set of overrides that every browser test platform port should have.""" |
+ def create_driver(self, worker_number, no_timeout=False): |
+ return self._driver_class()(self, worker_number, pixel_tests=self.get_option('pixel_tests'), no_timeout=no_timeout) |
Dirk Pranke
2014/07/10 23:37:13
I don't think you need to override create_driver()
ivandavid
2014/07/16 21:29:01
Done.
|
+ |
+ def _driver_class(self): |
+ return browser_test_driver.BrowserTestDriver |
+ |
+ def layout_tests_dir(self): |
+ """Overriden function from the base port class. Redirects everything |
+ to src/chrome/test/data/printing/layout_tests. |
+ """ |
+ return self.path_from_chromium_base('chrome', 'test', 'data', 'printing', 'layout_tests', 'tests') |
+ |
+ def default_results_directory(self): |
+ """Overriden function from base port class. Uses |
+ src/chrome/test/data/printing/layout_tests/results to store test results. |
+ """ |
+ return self.path_from_chromium_base('chrome', 'test', 'data', 'printing', 'layout_tests', 'results') |
Dirk Pranke
2014/07/10 23:37:13
this is probably not the best place to write the r
ivandavid
2014/07/16 21:29:00
Done.
ivandavid
2014/07/16 21:29:01
Actually, I think we can just keep everything in a
|
+ |
+ |
+class BrowserTestPort(object): |
ivandavid
2014/07/10 22:39:09
I decided to to make a class that creates the port
Dirk Pranke
2014/07/10 23:37:13
Unfortunately, while our coding style allows for m
ivandavid
2014/07/16 21:29:00
OK. I changed it, I don't think I exercised much f
ivandavid
2014/07/16 21:29:01
Done.
|
+ """Created by factory.py, this class creates platform specific ports given |
+ a port name. For example, if run_webkit_tests.py is launched with the |
+ options '--platform browser_tests_linux' this class will create a class |
+ that inherits from linux.LinuxPort and BrowserTestPortOverrides. |
+ """ |
+ port_name = 'browser_test' |
+ |
+ def __init__(self, host, port_name, **kwargs): |
+ super(BrowserTestPort, self).__init__(host, port_name, **kwargs) |
+ |
+ def __new__(cls, host, port_name, **kwargs): |
+ if 'linux' in port_name: |
+ cls = type('BrowserTestLinuxPort', |
+ (cls, linux.LinuxPort, BrowserTestPortOverrides,), |
+ {}) |
+ elif 'mac' in port_name: |
+ cls = type('BrowserTestMacPort', |
+ (cls, mac.MacPort, BrowserTestPortOverrides,), |
+ {}) |
+ elif 'win' in port_name: |
+ cls = type('BrowserTestWinPort', |
+ (cls, win.WinPort, BrowserTestPortOverrides,), |
+ {}) |
+ return super(BrowserTestPort, cls).__new__(cls, |
+ host, |
+ port_name, |
+ **kwargs) |
+ |
+ @classmethod |
+ def determine_full_port_name(cls, host, options, port_name): |
+ """Returns the port name for the correct platform, given a port_name. |
+ The port_name passed into this function is the port name from |
+ the option '--platform.' port_name must always begin with |
+ 'browser_test' and end with '_*' where * is a platform, such as |
+ 'linux', 'mac', etc. |
+ """ |
+ if 'linux' in port_name: |
+ index = port_name.find('linux') |
+ name_string = 'linux' |
+ if index != -1: |
+ name_string = port_name[index:] |
+ return linux.LinuxPort.determine_full_port_name(host, |
+ options, |
+ name_string) |
+ elif 'mac' in port_name: |
+ index = port_name.find('mac') |
+ name_string = 'mac' |
+ if index != -1: |
+ name_string = port_name[index:] |
+ return mac.MacPort.determine_full_port_name(host, |
+ options, |
+ name_string) |
+ elif 'win' in port_name: |
+ index = port_name.find('win') |
+ name_string = 'win' |
+ if index != -1: |
+ name_string = port_name[index:] |
+ return win.WinPort.determine_full_port_name(host, |
+ options, |
+ name_string) |
+ else: |
+ return None |