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 unittest 30 31 from webkitpy.thirdparty.mock import Mock 32 33 from webkitpy.layout_tests.port import chromium_mac 34 from webkitpy.layout_tests.port import port_testcase 35 36 37 class ChromiumMacPortTest(port_testcase.PortTestCase): 38 def port_maker(self, platform): 39 if platform != 'darwin': 40 return None 41 return chromium_mac.ChromiumMacPort 42 43 def test_check_wdiff_install(self): 44 port = chromium_mac.ChromiumMacPort() 45 46 # Currently is always true, just logs if missing. 47 self.assertTrue(port._check_wdiff_install()) 48 49 def assert_name(self, port_name, os_version_string, expected): 50 port = chromium_mac.ChromiumMacPort(port_name=port_name, 51 os_version_string=os_version_string) 52 self.assertEquals(expected, port.name()) 53 54 def test_versions(self): 55 port = chromium_mac.ChromiumMacPort() 56 self.assertTrue(port.name() in ('chromium-mac-leopard', 'chromium-mac-snowleopard', 'chromium-mac-future')) 57 58 self.assert_name(None, '10.5.3', 'chromium-mac-leopard') 59 self.assert_name('chromium-mac', '10.5.3', 'chromium-mac-leopard') 60 self.assert_name('chromium-mac-leopard', '10.5.3', 'chromium-mac-leopard') 61 self.assert_name('chromium-mac-leopard', '10.6.3', 'chromium-mac-leopard') 62 63 self.assert_name(None, '10.6.3', 'chromium-mac-snowleopard') 64 self.assert_name('chromium-mac', '10.6.3', 'chromium-mac-snowleopard') 65 self.assert_name('chromium-mac-snowleopard', '10.5.3', 'chromium-mac-snowleopard') 66 self.assert_name('chromium-mac-snowleopard', '10.6.3', 'chromium-mac-snowleopard') 67 68 self.assert_name(None, '10.7', 'chromium-mac-future') 69 self.assert_name(None, '10.7.3', 'chromium-mac-future') 70 self.assert_name(None, '10.8', 'chromium-mac-future') 71 self.assert_name('chromium-mac', '10.7.3', 'chromium-mac-future') 72 self.assert_name('chromium-mac-future', '10.4.3', 'chromium-mac-future') 73 self.assert_name('chromium-mac-future', '10.5.3', 'chromium-mac-future') 74 self.assert_name('chromium-mac-future', '10.6.3', 'chromium-mac-future') 75 self.assert_name('chromium-mac-future', '10.7.3', 'chromium-mac-future') 76 77 self.assertRaises(AssertionError, self.assert_name, None, '10.4.1', 'should-raise-assertion-so-this-value-does-not-matter') 78 79 def test_baseline_path(self): 80 port = chromium_mac.ChromiumMacPort(port_name='chromium-mac-leopard') 81 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac-leopard')) 82 83 port = chromium_mac.ChromiumMacPort(port_name='chromium-mac-snowleopard') 84 self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-mac')) 85 86 87 if __name__ == '__main__': 88 unittest.main() 89