| OLD | NEW |
| (Empty) |
| 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 os | |
| 30 import unittest2 as unittest | |
| 31 | |
| 32 from webkitpy.common.system import outputcapture | |
| 33 from webkitpy.common.system.executive_mock import MockExecutive | |
| 34 from webkitpy.common.system.filesystem_mock import MockFileSystem | |
| 35 from webkitpy.layout_tests.port import chromium_port_testcase | |
| 36 from webkitpy.layout_tests.port import chromium_win | |
| 37 from webkitpy.tool.mocktool import MockOptions | |
| 38 | |
| 39 | |
| 40 class ChromiumWinTest(chromium_port_testcase.ChromiumPortTestCase): | |
| 41 port_name = 'chromium-win' | |
| 42 port_maker = chromium_win.ChromiumWinPort | |
| 43 os_name = 'win' | |
| 44 os_version = 'xp' | |
| 45 | |
| 46 def test_uses_apache(self): | |
| 47 self.assertFalse(self.make_port()._uses_apache()) | |
| 48 | |
| 49 def test_setup_environ_for_server(self): | |
| 50 port = self.make_port() | |
| 51 port._executive = MockExecutive(should_log=True) | |
| 52 output = outputcapture.OutputCapture() | |
| 53 # FIXME: This test should not use the real os.environ | |
| 54 orig_environ = os.environ.copy() | |
| 55 env = output.assert_outputs(self, port.setup_environ_for_server) | |
| 56 self.assertEqual(orig_environ["PATH"], os.environ["PATH"]) | |
| 57 self.assertNotEqual(env["PATH"], os.environ["PATH"]) | |
| 58 | |
| 59 def test_setup_environ_for_server_cygpath(self): | |
| 60 port = self.make_port() | |
| 61 env = port.setup_environ_for_server(port.driver_name()) | |
| 62 self.assertEqual(env['CYGWIN_PATH'], '/mock-checkout/Source/WebKit/chrom
ium/third_party/cygwin/bin') | |
| 63 | |
| 64 def test_setup_environ_for_server_register_cygwin(self): | |
| 65 port = self.make_port(options=MockOptions(register_cygwin=True, results_
directory='/')) | |
| 66 port._executive = MockExecutive(should_log=True) | |
| 67 expected_logs = "MOCK run_command: ['/mock-checkout/Source/WebKit/chromi
um/third_party/cygwin/setup_mount.bat'], cwd=None\n" | |
| 68 output = outputcapture.OutputCapture() | |
| 69 output.assert_outputs(self, port.setup_environ_for_server, expected_logs
=expected_logs) | |
| 70 | |
| 71 def assert_name(self, port_name, os_version_string, expected): | |
| 72 port = self.make_port(port_name=port_name, os_version=os_version_string) | |
| 73 self.assertEqual(expected, port.name()) | |
| 74 | |
| 75 def test_versions(self): | |
| 76 port = self.make_port() | |
| 77 self.assertIn(port.name(), ('chromium-win-xp', 'chromium-win-win7')) | |
| 78 | |
| 79 self.assert_name(None, 'xp', 'chromium-win-xp') | |
| 80 self.assert_name('chromium-win', 'xp', 'chromium-win-xp') | |
| 81 self.assert_name('chromium-win-xp', 'xp', 'chromium-win-xp') | |
| 82 self.assert_name('chromium-win-xp', '7sp0', 'chromium-win-xp') | |
| 83 | |
| 84 self.assert_name(None, '7sp0', 'chromium-win-win7') | |
| 85 self.assert_name(None, 'vista', 'chromium-win-win7') | |
| 86 self.assert_name('chromium-win', '7sp0', 'chromium-win-win7') | |
| 87 self.assert_name('chromium-win-win7', 'xp', 'chromium-win-win7') | |
| 88 self.assert_name('chromium-win-win7', '7sp0', 'chromium-win-win7') | |
| 89 self.assert_name('chromium-win-win7', 'vista', 'chromium-win-win7') | |
| 90 | |
| 91 self.assertRaises(AssertionError, self.assert_name, None, 'w2k', 'chromi
um-win-xp') | |
| 92 | |
| 93 def test_baseline_path(self): | |
| 94 port = self.make_port(port_name='chromium-win-xp') | |
| 95 self.assertEqual(port.baseline_path(), port._webkit_baseline_path('chrom
ium-win-xp')) | |
| 96 | |
| 97 port = self.make_port(port_name='chromium-win-win7') | |
| 98 self.assertEqual(port.baseline_path(), port._webkit_baseline_path('chrom
ium-win')) | |
| 99 | |
| 100 def test_build_path(self): | |
| 101 # Test that optional paths are used regardless of whether they exist. | |
| 102 options = MockOptions(configuration='Release', build_directory='/foo') | |
| 103 self.assert_build_path(options, ['/mock-checkout/Source/WebKit/chromium/
out/Release'], '/foo/Release') | |
| 104 | |
| 105 # Test that optional relative paths are returned unmodified. | |
| 106 options = MockOptions(configuration='Release', build_directory='foo') | |
| 107 self.assert_build_path(options, ['/mock-checkout/Source/WebKit/chromium/
out/Release'], 'foo/Release') | |
| 108 | |
| 109 # Test that we prefer the legacy dir over the new dir. | |
| 110 options = MockOptions(configuration='Release', build_directory=None) | |
| 111 self.assert_build_path(options, ['/mock-checkout/Source/WebKit/chromium/
build/Release', '/mock-checkout/Source/WebKit/chromium/out'], '/mock-checkout/So
urce/WebKit/chromium/build/Release') | |
| 112 | |
| 113 def test_build_path_timestamps(self): | |
| 114 options = MockOptions(configuration='Release', build_directory=None) | |
| 115 port = self.make_port(options=options) | |
| 116 port.host.filesystem.maybe_make_directory('/mock-checkout/out/Release') | |
| 117 port.host.filesystem.maybe_make_directory('/mock-checkout/build/Release'
) | |
| 118 # Check with 'out' being newer. | |
| 119 port.host.filesystem.mtime = lambda f: 5 if '/out/' in f else 4 | |
| 120 self.assertEqual(port._build_path(), '/mock-checkout/out/Release') | |
| 121 # Check with 'build' being newer. | |
| 122 port.host.filesystem.mtime = lambda f: 5 if '/build/' in f else 4 | |
| 123 self.assertEqual(port._build_path(), '/mock-checkout/build/Release') | |
| 124 | |
| 125 def test_operating_system(self): | |
| 126 self.assertEqual('win', self.make_port().operating_system()) | |
| 127 | |
| 128 def test_driver_name_option(self): | |
| 129 self.assertTrue(self.make_port()._path_to_driver().endswith('content_she
ll.exe')) | |
| 130 self.assertTrue(self.make_port(options=MockOptions(driver_name='OtherDri
ver'))._path_to_driver().endswith('OtherDriver.exe')) | |
| 131 | |
| 132 def test_path_to_image_diff(self): | |
| 133 self.assertEqual(self.make_port()._path_to_image_diff(), '/mock-checkout
/out/Release/ImageDiff.exe') | |
| OLD | NEW |