Home | History | Annotate | Download | only in port
      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 unittest
     28 
     29 from webkitpy.tool import mocktool
     30 import chromium_gpu
     31 
     32 from webkitpy.layout_tests.port import factory
     33 
     34 class ChromiumGpuTest(unittest.TestCase):
     35     def test_get_chromium_gpu_linux(self):
     36         self.assertOverridesWorked('chromium-gpu-linux')
     37 
     38     def test_get_chromium_gpu_mac(self):
     39         self.assertOverridesWorked('chromium-gpu-mac')
     40 
     41     def test_get_chromium_gpu_win(self):
     42         self.assertOverridesWorked('chromium-gpu-win')
     43 
     44     def test_get_chromium_gpu__on_linux(self):
     45         self.assertOverridesWorked('chromium-gpu-linux', 'chromium-gpu', 'linux2')
     46 
     47     def test_get_chromium_gpu__on_mac(self):
     48         self.assertOverridesWorked('chromium-gpu-mac', 'chromium-gpu', 'darwin')
     49 
     50     def test_get_chromium_gpu__on_win(self):
     51         self.assertOverridesWorked('chromium-gpu-win', 'chromium-gpu', 'win32')
     52         self.assertOverridesWorked('chromium-gpu-win', 'chromium-gpu', 'cygwin')
     53 
     54     def assertOverridesWorked(self, port_name, input_name=None, platform=None):
     55         # test that we got the right port
     56         mock_options = mocktool.MockOptions(accelerated_compositing=None,
     57                                             accelerated_2d_canvas=None,
     58                                             builder_name='foo',
     59                                             child_processes=None)
     60         if input_name and platform:
     61             port = chromium_gpu.get(platform=platform, port_name=input_name,
     62                                     options=mock_options)
     63         else:
     64             port = chromium_gpu.get(port_name=port_name, options=mock_options)
     65         self.assertTrue(port._options.accelerated_compositing)
     66         self.assertTrue(port._options.accelerated_2d_canvas)
     67         self.assertEqual(port.default_child_processes(), 1)
     68         self.assertEqual(port._options.builder_name, 'foo - GPU')
     69 
     70         self.assertTrue(port.name().startswith(port_name))
     71 
     72         # test that it has the right directories in front of the search path.
     73         paths = port.baseline_search_path()
     74         self.assertEqual(port._webkit_baseline_path(port_name), paths[0])
     75         if port_name == 'chromium-gpu-linux':
     76             self.assertEqual(port._webkit_baseline_path('chromium-gpu-win'), paths[1])
     77             self.assertEqual(port._webkit_baseline_path('chromium-gpu'), paths[2])
     78         else:
     79             self.assertEqual(port._webkit_baseline_path('chromium-gpu'), paths[1])
     80 
     81 
     82         # Test that we're limiting to the correct directories.
     83         # These two tests are picked mostly at random, but we make sure they
     84         # exist separately from being filtered out by the port.
     85         files = port.tests(None)
     86 
     87         path = port.abspath_for_test('compositing/checkerboard.html')
     88         self.assertTrue(port._filesystem.exists(path))
     89         self.assertTrue(path in files)
     90 
     91         path = port.abspath_for_test('fast/html/keygen.html')
     92         self.assertTrue(port._filesystem.exists(path))
     93         self.assertFalse(path in files)
     94         if port_name.startswith('chromium-gpu-mac'):
     95             path = port.abspath_for_test('fast/canvas/set-colors.html')
     96             self.assertTrue(port._filesystem.exists(path))
     97             self.assertFalse(path in files)
     98 
     99     def test_chromium_gpu__vista(self):
    100         port = factory.get('chromium-gpu-win-vista')
    101         self.assertEquals(port.name(), 'chromium-gpu-win-vista')
    102         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-gpu-win'))
    103 
    104     def test_chromium_gpu__xp(self):
    105         port = factory.get('chromium-gpu-win-xp')
    106         self.assertEquals(port.name(), 'chromium-gpu-win-xp')
    107         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-gpu-win'))
    108 
    109     def test_chromium_gpu__win7(self):
    110         port = factory.get('chromium-gpu-win-win7')
    111         self.assertEquals(port.name(), 'chromium-gpu-win-win7')
    112         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-gpu-win'))
    113 
    114     def test_chromium_gpu__leopard(self):
    115         port = factory.get('chromium-gpu-mac-leopard')
    116         self.assertEquals(port.name(), 'chromium-gpu-mac-leopard')
    117         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-gpu-mac'))
    118 
    119     def test_chromium_gpu__snowleopard(self):
    120         port = factory.get('chromium-gpu-mac-snowleopard')
    121         self.assertEquals(port.name(), 'chromium-gpu-mac-snowleopard')
    122         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-gpu-mac'))
    123 
    124 
    125 if __name__ == '__main__':
    126     unittest.main()
    127