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