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 15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 27 import sys 28 29 import chromium_linux 30 import chromium_mac 31 import chromium_win 32 33 from webkitpy.layout_tests.port import test_files 34 35 36 def get(platform=None, port_name='chromium-gpu', **kwargs): 37 """Some tests have slightly different results when run while using 38 hardware acceleration. In those cases, we prepend an additional directory 39 to the baseline paths.""" 40 platform = platform or sys.platform 41 if port_name == 'chromium-gpu': 42 if platform in ('cygwin', 'win32'): 43 port_name = 'chromium-gpu-win' 44 elif platform == 'linux2': 45 port_name = 'chromium-gpu-linux' 46 elif platform == 'darwin': 47 port_name = 'chromium-gpu-mac' 48 else: 49 raise NotImplementedError('unsupported platform: %s' % platform) 50 51 if port_name.startswith('chromium-gpu-linux'): 52 return ChromiumGpuLinuxPort(port_name=port_name, **kwargs) 53 if port_name.startswith('chromium-gpu-mac'): 54 return ChromiumGpuMacPort(port_name=port_name, **kwargs) 55 if port_name.startswith('chromium-gpu-win'): 56 return ChromiumGpuWinPort(port_name=port_name, **kwargs) 57 raise NotImplementedError('unsupported port: %s' % port_name) 58 59 60 # FIXME: These should really be a mixin class. 61 62 def _set_gpu_options(port): 63 port._graphics_type = 'gpu' 64 if port.get_option('accelerated_compositing') is None: 65 port._options.accelerated_compositing = True 66 if port.get_option('accelerated_2d_canvas') is None: 67 port._options.accelerated_2d_canvas = True 68 69 # FIXME: Remove this after http://codereview.chromium.org/5133001/ is enabled 70 # on the bots. 71 if port.get_option('builder_name') is not None and not ' - GPU' in port._options.builder_name: 72 port._options.builder_name += ' - GPU' 73 74 75 def _tests(port, paths): 76 if not paths: 77 paths = ['compositing', 'platform/chromium/compositing', 'media'] 78 if not port.name().startswith('chromium-gpu-mac'): 79 # Canvas is not yet accelerated on the Mac, so there's no point 80 # in running the tests there. 81 paths += ['fast/canvas', 'canvas/philip'] 82 # invalidate_rect.html tests a bug in the compositor. 83 # See https://bugs.webkit.org/show_bug.cgi?id=53117 84 paths += ['plugins/invalidate_rect.html'] 85 return test_files.find(port, paths) 86 87 88 class ChromiumGpuLinuxPort(chromium_linux.ChromiumLinuxPort): 89 def __init__(self, port_name='chromium-gpu-linux', **kwargs): 90 chromium_linux.ChromiumLinuxPort.__init__(self, port_name=port_name, **kwargs) 91 _set_gpu_options(self) 92 93 def baseline_path(self): 94 # GPU baselines aren't yet versioned. 95 return self._webkit_baseline_path('chromium-gpu-linux') 96 97 def baseline_search_path(self): 98 # Mimic the Linux -> Win expectations fallback in the ordinary Chromium port. 99 return (map(self._webkit_baseline_path, ['chromium-gpu-linux', 'chromium-gpu-win', 'chromium-gpu']) + 100 chromium_linux.ChromiumLinuxPort.baseline_search_path(self)) 101 102 def default_child_processes(self): 103 return 1 104 105 def tests(self, paths): 106 return _tests(self, paths) 107 108 109 class ChromiumGpuMacPort(chromium_mac.ChromiumMacPort): 110 def __init__(self, port_name='chromium-gpu-mac', **kwargs): 111 chromium_mac.ChromiumMacPort.__init__(self, port_name=port_name, **kwargs) 112 _set_gpu_options(self) 113 114 def baseline_path(self): 115 # GPU baselines aren't yet versioned. 116 return self._webkit_baseline_path('chromium-gpu-mac') 117 118 def baseline_search_path(self): 119 return (map(self._webkit_baseline_path, ['chromium-gpu-mac', 'chromium-gpu']) + 120 chromium_mac.ChromiumMacPort.baseline_search_path(self)) 121 122 def default_child_processes(self): 123 return 1 124 125 def tests(self, paths): 126 return _tests(self, paths) 127 128 129 class ChromiumGpuWinPort(chromium_win.ChromiumWinPort): 130 def __init__(self, port_name='chromium-gpu-win', **kwargs): 131 chromium_win.ChromiumWinPort.__init__(self, port_name=port_name, **kwargs) 132 _set_gpu_options(self) 133 134 def baseline_path(self): 135 # GPU baselines aren't yet versioned. 136 return self._webkit_baseline_path('chromium-gpu-win') 137 138 def baseline_search_path(self): 139 return (map(self._webkit_baseline_path, ['chromium-gpu-win', 'chromium-gpu']) + 140 chromium_win.ChromiumWinPort.baseline_search_path(self)) 141 142 def default_child_processes(self): 143 return 1 144 145 def tests(self, paths): 146 return _tests(self, paths) 147