Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py

Issue 546133003: Reformat webkitpy.layout_tests w/ format-webkitpy. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 22 matching lines...) Expand all
33 from webkitpy.layout_tests.port import Port, Driver, DriverOutput 33 from webkitpy.layout_tests.port import Port, Driver, DriverOutput
34 from webkitpy.layout_tests.port.server_process_mock import MockServerProcess 34 from webkitpy.layout_tests.port.server_process_mock import MockServerProcess
35 35
36 # FIXME: remove the dependency on TestWebKitPort 36 # FIXME: remove the dependency on TestWebKitPort
37 from webkitpy.layout_tests.port.port_testcase import TestWebKitPort 37 from webkitpy.layout_tests.port.port_testcase import TestWebKitPort
38 38
39 from webkitpy.tool.mocktool import MockOptions 39 from webkitpy.tool.mocktool import MockOptions
40 40
41 41
42 class DriverTest(unittest.TestCase): 42 class DriverTest(unittest.TestCase):
43
43 def make_port(self): 44 def make_port(self):
44 port = Port(MockSystemHost(), 'test', MockOptions(configuration='Release ')) 45 port = Port(MockSystemHost(), 'test', MockOptions(configuration='Release '))
45 port._config.build_directory = lambda configuration: '/mock-checkout/out /' + configuration 46 port._config.build_directory = lambda configuration: '/mock-checkout/out /' + configuration
46 return port 47 return port
47 48
48 def _assert_wrapper(self, wrapper_string, expected_wrapper): 49 def _assert_wrapper(self, wrapper_string, expected_wrapper):
49 wrapper = Driver(self.make_port(), None, pixel_tests=False)._command_wra pper(wrapper_string) 50 wrapper = Driver(self.make_port(), None, pixel_tests=False)._command_wra pper(wrapper_string)
50 self.assertEqual(wrapper, expected_wrapper) 51 self.assertEqual(wrapper, expected_wrapper)
51 52
52 def test_command_wrapper(self): 53 def test_command_wrapper(self):
53 self._assert_wrapper(None, []) 54 self._assert_wrapper(None, [])
54 self._assert_wrapper("valgrind", ["valgrind"]) 55 self._assert_wrapper('valgrind', ['valgrind'])
55 56
56 # Validate that shlex works as expected. 57 # Validate that shlex works as expected.
57 command_with_spaces = "valgrind --smc-check=\"check with spaces!\" --foo " 58 command_with_spaces = 'valgrind --smc-check=\'check with spaces!\' --foo '
58 expected_parse = ["valgrind", "--smc-check=check with spaces!", "--foo"] 59 expected_parse = ['valgrind', '--smc-check=check with spaces!', '--foo']
59 self._assert_wrapper(command_with_spaces, expected_parse) 60 self._assert_wrapper(command_with_spaces, expected_parse)
60 61
61 def test_test_to_uri(self): 62 def test_test_to_uri(self):
62 port = self.make_port() 63 port = self.make_port()
63 driver = Driver(port, None, pixel_tests=False) 64 driver = Driver(port, None, pixel_tests=False)
64 self.assertEqual(driver.test_to_uri('foo/bar.html'), 'file://%s/foo/bar. html' % port.layout_tests_dir()) 65 self.assertEqual(driver.test_to_uri('foo/bar.html'), 'file://%s/foo/bar. html' % port.layout_tests_dir())
65 self.assertEqual(driver.test_to_uri('http/tests/foo.html'), 'http://127. 0.0.1:8000/foo.html') 66 self.assertEqual(driver.test_to_uri('http/tests/foo.html'), 'http://127. 0.0.1:8000/foo.html')
66 self.assertEqual(driver.test_to_uri('http/tests/https/bar.html'), 'https ://127.0.0.1:8443/https/bar.html') 67 self.assertEqual(driver.test_to_uri('http/tests/https/bar.html'), 'https ://127.0.0.1:8443/https/bar.html')
67 68
68 def test_uri_to_test(self): 69 def test_uri_to_test(self):
69 port = self.make_port() 70 port = self.make_port()
70 driver = Driver(port, None, pixel_tests=False) 71 driver = Driver(port, None, pixel_tests=False)
71 self.assertEqual(driver.uri_to_test('file://%s/foo/bar.html' % port.layo ut_tests_dir()), 'foo/bar.html') 72 self.assertEqual(driver.uri_to_test('file://%s/foo/bar.html' % port.layo ut_tests_dir()), 'foo/bar.html')
72 self.assertEqual(driver.uri_to_test('http://127.0.0.1:8000/foo.html'), ' http/tests/foo.html') 73 self.assertEqual(driver.uri_to_test('http://127.0.0.1:8000/foo.html'), ' http/tests/foo.html')
73 self.assertEqual(driver.uri_to_test('https://127.0.0.1:8443/https/bar.ht ml'), 'http/tests/https/bar.html') 74 self.assertEqual(driver.uri_to_test('https://127.0.0.1:8443/https/bar.ht ml'), 'http/tests/https/bar.html')
74 75
75 def test_read_block(self): 76 def test_read_block(self):
76 port = TestWebKitPort() 77 port = TestWebKitPort()
77 driver = Driver(port, 0, pixel_tests=False) 78 driver = Driver(port, 0, pixel_tests=False)
78 driver._server_process = MockServerProcess(lines=[ 79 driver._server_process = MockServerProcess(lines=[
79 'ActualHash: foobar', 80 'ActualHash: foobar',
80 'Content-Type: my_type', 81 'Content-Type: my_type',
81 'Content-Transfer-Encoding: none', 82 'Content-Transfer-Encoding: none',
82 "#EOF", 83 '#EOF',
83 ]) 84 ])
84 content_block = driver._read_block(0) 85 content_block = driver._read_block(0)
85 self.assertEqual(content_block.content, '') 86 self.assertEqual(content_block.content, '')
86 self.assertEqual(content_block.content_type, 'my_type') 87 self.assertEqual(content_block.content_type, 'my_type')
87 self.assertEqual(content_block.encoding, 'none') 88 self.assertEqual(content_block.encoding, 'none')
88 self.assertEqual(content_block.content_hash, 'foobar') 89 self.assertEqual(content_block.content_hash, 'foobar')
89 driver._server_process = None 90 driver._server_process = None
90 91
91 def test_read_binary_block(self): 92 def test_read_binary_block(self):
92 port = TestWebKitPort() 93 port = TestWebKitPort()
93 driver = Driver(port, 0, pixel_tests=True) 94 driver = Driver(port, 0, pixel_tests=True)
94 driver._server_process = MockServerProcess(lines=[ 95 driver._server_process = MockServerProcess(lines=[
95 'ActualHash: actual', 96 'ActualHash: actual',
96 'ExpectedHash: expected', 97 'ExpectedHash: expected',
97 'Content-Type: image/png', 98 'Content-Type: image/png',
98 'Content-Length: 9', 99 'Content-Length: 9',
99 "12345678", 100 '12345678',
100 "#EOF", 101 '#EOF',
101 ]) 102 ])
102 content_block = driver._read_block(0) 103 content_block = driver._read_block(0)
103 self.assertEqual(content_block.content_type, 'image/png') 104 self.assertEqual(content_block.content_type, 'image/png')
104 self.assertEqual(content_block.content_hash, 'actual') 105 self.assertEqual(content_block.content_hash, 'actual')
105 self.assertEqual(content_block.content, '12345678\n') 106 self.assertEqual(content_block.content, '12345678\n')
106 self.assertEqual(content_block.decoded_content, '12345678\n') 107 self.assertEqual(content_block.decoded_content, '12345678\n')
107 driver._server_process = None 108 driver._server_process = None
108 109
109 def test_read_base64_block(self): 110 def test_read_base64_block(self):
110 port = TestWebKitPort() 111 port = TestWebKitPort()
(...skipping 10 matching lines...) Expand all
121 self.assertEqual(content_block.content_type, 'image/png') 122 self.assertEqual(content_block.content_type, 'image/png')
122 self.assertEqual(content_block.content_hash, 'actual') 123 self.assertEqual(content_block.content_hash, 'actual')
123 self.assertEqual(content_block.encoding, 'base64') 124 self.assertEqual(content_block.encoding, 'base64')
124 self.assertEqual(content_block.content, 'MTIzNDU2NzgK') 125 self.assertEqual(content_block.content, 'MTIzNDU2NzgK')
125 self.assertEqual(content_block.decoded_content, '12345678\n') 126 self.assertEqual(content_block.decoded_content, '12345678\n')
126 127
127 def test_no_timeout(self): 128 def test_no_timeout(self):
128 port = TestWebKitPort() 129 port = TestWebKitPort()
129 port._config.build_directory = lambda configuration: '/mock-checkout/out /' + configuration 130 port._config.build_directory = lambda configuration: '/mock-checkout/out /' + configuration
130 driver = Driver(port, 0, pixel_tests=True, no_timeout=True) 131 driver = Driver(port, 0, pixel_tests=True, no_timeout=True)
131 self.assertEqual(driver.cmd_line(True, []), ['/mock-checkout/out/Release /content_shell', '--no-timeout', '--dump-render-tree', '-']) 132 self.assertEqual(
133 driver.cmd_line(
134 True, []), [
135 '/mock-checkout/out/Release/content_shell', '--no-timeout', '--d ump-render-tree', '-'])
132 136
133 def test_check_for_driver_crash(self): 137 def test_check_for_driver_crash(self):
134 port = TestWebKitPort() 138 port = TestWebKitPort()
135 driver = Driver(port, 0, pixel_tests=True) 139 driver = Driver(port, 0, pixel_tests=True)
136 140
137 class FakeServerProcess(object): 141 class FakeServerProcess(object):
142
138 def __init__(self, crashed): 143 def __init__(self, crashed):
139 self.crashed = crashed 144 self.crashed = crashed
140 145
141 def pid(self): 146 def pid(self):
142 return 1234 147 return 1234
143 148
144 def name(self): 149 def name(self):
145 return 'FakeServerProcess' 150 return 'FakeServerProcess'
146 151
147 def has_crashed(self): 152 def has_crashed(self):
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 last_tmpdir = port._filesystem.last_tmpdir 239 last_tmpdir = port._filesystem.last_tmpdir
235 driver._start(True, []) 240 driver._start(True, [])
236 self.assertFalse(port._filesystem.isdir(last_tmpdir)) 241 self.assertFalse(port._filesystem.isdir(last_tmpdir))
237 242
238 def test_start_actually_starts(self): 243 def test_start_actually_starts(self):
239 port = TestWebKitPort() 244 port = TestWebKitPort()
240 port._server_process_constructor = MockServerProcess 245 port._server_process_constructor = MockServerProcess
241 driver = Driver(port, 0, pixel_tests=True) 246 driver = Driver(port, 0, pixel_tests=True)
242 driver.start(True, [], None) 247 driver.start(True, [], None)
243 self.assertTrue(driver._server_process.started) 248 self.assertTrue(driver._server_process.started)
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/layout_tests/port/driver.py ('k') | Tools/Scripts/webkitpy/layout_tests/port/factory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698