Home | History | Annotate | Download | only in port
      1 # Copyright (C) 2010 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 name of Google Inc. 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 import StringIO
     30 import sys
     31 import unittest
     32 
     33 from webkitpy.layout_tests.port import mac
     34 from webkitpy.layout_tests.port import port_testcase
     35 
     36 
     37 class MacTest(port_testcase.PortTestCase):
     38     def port_maker(self, platform):
     39         if platform != 'darwin':
     40             return None
     41         return mac.MacPort
     42 
     43     def assert_skipped_files_for_version(self, port_name, expected_paths):
     44         port = mac.MacPort(port_name=port_name)
     45         skipped_paths = port._skipped_file_paths()
     46         # FIXME: _skipped_file_paths should return WebKit-relative paths.
     47         # So to make it unit testable, we strip the WebKit directory from the path.
     48         relative_paths = [path[len(port.path_from_webkit_base()):] for path in skipped_paths]
     49         self.assertEqual(relative_paths, expected_paths)
     50 
     51     def test_skipped_file_paths(self):
     52         # We skip this on win32 because we use '/' as the dir separator and it's
     53         # not worth making platform-independent.
     54         if sys.platform == 'win32':
     55             return None
     56 
     57         self.assert_skipped_files_for_version('mac-snowleopard',
     58             ['/LayoutTests/platform/mac-snowleopard/Skipped', '/LayoutTests/platform/mac/Skipped'])
     59         self.assert_skipped_files_for_version('mac-leopard',
     60             ['/LayoutTests/platform/mac-leopard/Skipped', '/LayoutTests/platform/mac/Skipped'])
     61 
     62     example_skipped_file = u"""
     63 # <rdar://problem/5647952> fast/events/mouseout-on-window.html needs mac DRT to issue mouse out events
     64 fast/events/mouseout-on-window.html
     65 
     66 # <rdar://problem/5643675> window.scrollTo scrolls a window with no scrollbars
     67 fast/events/attempt-scroll-with-no-scrollbars.html
     68 
     69 # see bug <rdar://problem/5646437> REGRESSION (r28015): svg/batik/text/smallFonts fails
     70 svg/batik/text/smallFonts.svg
     71 """
     72     example_skipped_tests = [
     73         "fast/events/mouseout-on-window.html",
     74         "fast/events/attempt-scroll-with-no-scrollbars.html",
     75         "svg/batik/text/smallFonts.svg",
     76     ]
     77 
     78     def test_tests_from_skipped_file_contents(self):
     79         port = mac.MacPort()
     80         self.assertEqual(port._tests_from_skipped_file_contents(self.example_skipped_file), self.example_skipped_tests)
     81 
     82     def assert_name(self, port_name, os_version_string, expected):
     83         port = mac.MacPort(port_name=port_name,
     84                            os_version_string=os_version_string)
     85         self.assertEquals(expected, port.name())
     86 
     87     def test_tests_for_other_platforms(self):
     88         port = mac.MacPort(port_name='mac-snowleopard')
     89         dirs_to_skip = port._tests_for_other_platforms()
     90         self.assertTrue('platform/chromium-linux' in dirs_to_skip)
     91         self.assertTrue('platform/mac-tiger' in dirs_to_skip)
     92         self.assertFalse('platform/mac' in dirs_to_skip)
     93         self.assertFalse('platform/mac-snowleopard' in dirs_to_skip)
     94 
     95     def test_version(self):
     96         port = mac.MacPort()
     97         self.assertTrue(port.version())
     98 
     99     def test_versions(self):
    100         port = self.make_port()
    101         if port:
    102             self.assertTrue(port.name() in ('mac-tiger', 'mac-leopard', 'mac-snowleopard', 'mac-future'))
    103 
    104         self.assert_name(None, '10.4.8', 'mac-tiger')
    105         self.assert_name('mac', '10.4.8', 'mac-tiger')
    106         self.assert_name('mac-tiger', '10.4.8', 'mac-tiger')
    107         self.assert_name('mac-tiger', '10.5.3', 'mac-tiger')
    108         self.assert_name('mac-tiger', '10.6.3', 'mac-tiger')
    109 
    110         self.assert_name(None, '10.5.3', 'mac-leopard')
    111         self.assert_name('mac', '10.5.3', 'mac-leopard')
    112         self.assert_name('mac-leopard', '10.4.8', 'mac-leopard')
    113         self.assert_name('mac-leopard', '10.5.3', 'mac-leopard')
    114         self.assert_name('mac-leopard', '10.6.3', 'mac-leopard')
    115 
    116         self.assert_name(None, '10.6.3', 'mac-snowleopard')
    117         self.assert_name('mac', '10.6.3', 'mac-snowleopard')
    118         self.assert_name('mac-snowleopard', '10.4.3', 'mac-snowleopard')
    119         self.assert_name('mac-snowleopard', '10.5.3', 'mac-snowleopard')
    120         self.assert_name('mac-snowleopard', '10.6.3', 'mac-snowleopard')
    121 
    122         self.assert_name(None, '10.7', 'mac-future')
    123         self.assert_name(None, '10.7.3', 'mac-future')
    124         self.assert_name(None, '10.8', 'mac-future')
    125         self.assert_name('mac', '10.7.3', 'mac-future')
    126         self.assert_name('mac-future', '10.4.3', 'mac-future')
    127         self.assert_name('mac-future', '10.5.3', 'mac-future')
    128         self.assert_name('mac-future', '10.6.3', 'mac-future')
    129         self.assert_name('mac-future', '10.7.3', 'mac-future')
    130 
    131         self.assertRaises(AssertionError, self.assert_name, None, '10.3.1', 'should-raise-assertion-so-this-value-does-not-matter')
    132 
    133 
    134 if __name__ == '__main__':
    135     unittest.main()
    136