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.common.system import filesystem_mock
     30 
     31 import factory
     32 import google_chrome
     33 
     34 
     35 class GetGoogleChromePortTest(unittest.TestCase):
     36     def test_get_google_chrome_port(self):
     37         test_ports = ('google-chrome-linux32', 'google-chrome-linux64',
     38             'google-chrome-mac', 'google-chrome-win')
     39         for port in test_ports:
     40             self._verify_baseline_path(port, port)
     41             self._verify_expectations_overrides(port)
     42 
     43         self._verify_baseline_path('google-chrome-mac', 'google-chrome-mac-leopard')
     44         self._verify_baseline_path('google-chrome-win', 'google-chrome-win-xp')
     45         self._verify_baseline_path('google-chrome-win', 'google-chrome-win-vista')
     46 
     47     def _verify_baseline_path(self, expected_path, port_name):
     48         port = google_chrome.GetGoogleChromePort(port_name=port_name,
     49                                                  options=None)
     50         path = port.baseline_search_path()[0]
     51         self.assertEqual(expected_path, port._filesystem.basename(path))
     52 
     53     def _verify_expectations_overrides(self, port_name):
     54         # FIXME: make this more robust when we have the Tree() abstraction.
     55         # we should be able to test for the files existing or not, and
     56         # be able to control the contents better.
     57 
     58         chromium_port = factory.get("chromium-mac")
     59         chromium_base = chromium_port.path_from_chromium_base()
     60         fs = filesystem_mock.MockFileSystem()
     61         port = google_chrome.GetGoogleChromePort(port_name=port_name,
     62                                                  options=None, filesystem=fs)
     63 
     64         expected_chromium_overrides = '// chromium overrides\n'
     65         expected_chrome_overrides = '// chrome overrides\n'
     66         chromium_path = fs.join(chromium_base, 'webkit', 'tools',
     67                                 'layout_tests', 'test_expectations.txt')
     68         chrome_path = fs.join(chromium_base, 'webkit', 'tools',
     69                               'layout_tests', 'test_expectations_chrome.txt')
     70 
     71         fs.files[chromium_path] = expected_chromium_overrides
     72         fs.files[chrome_path] = None
     73         actual_chrome_overrides = port.test_expectations_overrides()
     74         self.assertEqual(expected_chromium_overrides, actual_chrome_overrides)
     75 
     76         fs.files[chrome_path] = expected_chrome_overrides
     77         actual_chrome_overrides = port.test_expectations_overrides()
     78         self.assertEqual(actual_chrome_overrides,
     79                          expected_chromium_overrides + expected_chrome_overrides)
     80 
     81 
     82 if __name__ == '__main__':
     83     unittest.main()
     84