Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (C) 2014 Google Inc. All rights reserved. | |
| 2 # | |
| 3 # Redistribution and use in source and binary forms, with or without | |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 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 | |
| 12 # distribution. | |
| 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. | |
| 16 # | |
| 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. | |
| 28 | |
| 29 from webkitpy.layout_tests.port import base | |
| 30 from webkitpy.layout_tests.port import linux | |
| 31 from webkitpy.layout_tests.port import mac | |
| 32 from webkitpy.layout_tests.port import win | |
| 33 from webkitpy.layout_tests.port import browser_test_driver | |
| 34 | |
| 35 | |
| 36 class BrowserTestPortOverrides(base.Port): | |
| 37 """Set of overrides that every browser test platform port should have.""" | |
| 38 def create_driver(self, worker_number, no_timeout=False): | |
| 39 return self._driver_class()(self, worker_number, pixel_tests=self.get_op tion('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.
| |
| 40 | |
| 41 def _driver_class(self): | |
| 42 return browser_test_driver.BrowserTestDriver | |
| 43 | |
| 44 def layout_tests_dir(self): | |
| 45 """Overriden function from the base port class. Redirects everything | |
| 46 to src/chrome/test/data/printing/layout_tests. | |
| 47 """ | |
| 48 return self.path_from_chromium_base('chrome', 'test', 'data', 'printing' , 'layout_tests', 'tests') | |
| 49 | |
| 50 def default_results_directory(self): | |
| 51 """Overriden function from base port class. Uses | |
| 52 src/chrome/test/data/printing/layout_tests/results to store test results . | |
| 53 """ | |
| 54 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
| |
| 55 | |
| 56 | |
| 57 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.
| |
| 58 """Created by factory.py, this class creates platform specific ports given | |
| 59 a port name. For example, if run_webkit_tests.py is launched with the | |
| 60 options '--platform browser_tests_linux' this class will create a class | |
| 61 that inherits from linux.LinuxPort and BrowserTestPortOverrides. | |
| 62 """ | |
| 63 port_name = 'browser_test' | |
| 64 | |
| 65 def __init__(self, host, port_name, **kwargs): | |
| 66 super(BrowserTestPort, self).__init__(host, port_name, **kwargs) | |
| 67 | |
| 68 def __new__(cls, host, port_name, **kwargs): | |
| 69 if 'linux' in port_name: | |
| 70 cls = type('BrowserTestLinuxPort', | |
| 71 (cls, linux.LinuxPort, BrowserTestPortOverrides,), | |
| 72 {}) | |
| 73 elif 'mac' in port_name: | |
| 74 cls = type('BrowserTestMacPort', | |
| 75 (cls, mac.MacPort, BrowserTestPortOverrides,), | |
| 76 {}) | |
| 77 elif 'win' in port_name: | |
| 78 cls = type('BrowserTestWinPort', | |
| 79 (cls, win.WinPort, BrowserTestPortOverrides,), | |
| 80 {}) | |
| 81 return super(BrowserTestPort, cls).__new__(cls, | |
| 82 host, | |
| 83 port_name, | |
| 84 **kwargs) | |
| 85 | |
| 86 @classmethod | |
| 87 def determine_full_port_name(cls, host, options, port_name): | |
| 88 """Returns the port name for the correct platform, given a port_name. | |
| 89 The port_name passed into this function is the port name from | |
| 90 the option '--platform.' port_name must always begin with | |
| 91 'browser_test' and end with '_*' where * is a platform, such as | |
| 92 'linux', 'mac', etc. | |
| 93 """ | |
| 94 if 'linux' in port_name: | |
| 95 index = port_name.find('linux') | |
| 96 name_string = 'linux' | |
| 97 if index != -1: | |
| 98 name_string = port_name[index:] | |
| 99 return linux.LinuxPort.determine_full_port_name(host, | |
| 100 options, | |
| 101 name_string) | |
| 102 elif 'mac' in port_name: | |
| 103 index = port_name.find('mac') | |
| 104 name_string = 'mac' | |
| 105 if index != -1: | |
| 106 name_string = port_name[index:] | |
| 107 return mac.MacPort.determine_full_port_name(host, | |
| 108 options, | |
| 109 name_string) | |
| 110 elif 'win' in port_name: | |
| 111 index = port_name.find('win') | |
| 112 name_string = 'win' | |
| 113 if index != -1: | |
| 114 name_string = port_name[index:] | |
| 115 return win.WinPort.determine_full_port_name(host, | |
| 116 options, | |
| 117 name_string) | |
| 118 else: | |
| 119 return None | |
| OLD | NEW |