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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/port/mock_drt_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) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 pass 72 pass
73 73
74 def test_get_crash_log(self): 74 def test_get_crash_log(self):
75 pass 75 pass
76 76
77 def test_check_build(self): 77 def test_check_build(self):
78 pass 78 pass
79 79
80 80
81 class MockDRTTest(unittest.TestCase): 81 class MockDRTTest(unittest.TestCase):
82
82 def input_line(self, port, test_name, pixel_tests, checksum=None): 83 def input_line(self, port, test_name, pixel_tests, checksum=None):
83 url = port.create_driver(0).test_to_uri(test_name) 84 url = port.create_driver(0).test_to_uri(test_name)
84 if url.startswith('file://'): 85 if url.startswith('file://'):
85 url = url[len('file://'):] 86 url = url[len('file://'):]
86 if pixel_tests: 87 if pixel_tests:
87 url += "'--pixel-test" 88 url += "'--pixel-test"
88 if checksum: 89 if checksum:
89 url += "'" + checksum 90 url += "'" + checksum
90 return url + '\n' 91 return url + '\n'
91 92
(...skipping 25 matching lines...) Expand all
117 'ExpectedHash: %s\n' % expected_checksum]) 118 'ExpectedHash: %s\n' % expected_checksum])
118 output.append('#EOF\n') 119 output.append('#EOF\n')
119 return output 120 return output
120 121
121 def assertTest(self, test_name, pixel_tests, expected_checksum=None, drt_out put=None, host=None, expected_text=None): 122 def assertTest(self, test_name, pixel_tests, expected_checksum=None, drt_out put=None, host=None, expected_text=None):
122 port_name = 'test' 123 port_name = 'test'
123 host = host or MockSystemHost() 124 host = host or MockSystemHost()
124 test.add_unit_tests_to_mock_filesystem(host.filesystem) 125 test.add_unit_tests_to_mock_filesystem(host.filesystem)
125 port = PortFactory(host).get(port_name) 126 port = PortFactory(host).get(port_name)
126 drt_input, drt_output = self.make_input_output(port, test_name, 127 drt_input, drt_output = self.make_input_output(port, test_name,
127 pixel_tests, expected_checksum, drt_output, drt_input=None, expected _text=expected_text) 128 pixel_tests, expected_che cksum, drt_output, drt_input=None, expected_text=expected_text)
128 129
129 args = ['--dump-render-tree', '--platform', port_name, '-'] 130 args = ['--dump-render-tree', '--platform', port_name, '-']
130 stdin = io.BytesIO(drt_input) 131 stdin = io.BytesIO(drt_input)
131 stdout = io.BytesIO() 132 stdout = io.BytesIO()
132 stderr = io.BytesIO() 133 stderr = io.BytesIO()
133 options, args = mock_drt.parse_options(args) 134 options, args = mock_drt.parse_options(args)
134 135
135 drt = self.make_drt(options, args, host, stdin, stdout, stderr) 136 drt = self.make_drt(options, args, host, stdin, stdout, stderr)
136 res = drt.run() 137 res = drt.run()
137 138
(...skipping 14 matching lines...) Expand all
152 self.assertEqual(stdout.getvalue(), '') 153 self.assertEqual(stdout.getvalue(), '')
153 self.assertEqual(stderr.getvalue(), '') 154 self.assertEqual(stderr.getvalue(), '')
154 self.assertEqual(host.filesystem.written_files, {}) 155 self.assertEqual(host.filesystem.written_files, {})
155 156
156 def test_pixeltest_passes(self): 157 def test_pixeltest_passes(self):
157 # This also tests that we handle HTTP: test URLs properly. 158 # This also tests that we handle HTTP: test URLs properly.
158 self.assertTest('http/tests/passes/text.html', True) 159 self.assertTest('http/tests/passes/text.html', True)
159 160
160 def test_pixeltest__fails(self): 161 def test_pixeltest__fails(self):
161 self.assertTest('failures/expected/image_checksum.html', pixel_tests=Tru e, 162 self.assertTest('failures/expected/image_checksum.html', pixel_tests=Tru e,
162 expected_checksum='image_checksum-checksum', 163 expected_checksum='image_checksum-checksum',
163 drt_output=['Content-Type: text/plain\n', 164 drt_output=['Content-Type: text/plain\n',
164 'image_checksum-txt', 165 'image_checksum-txt',
165 '#EOF\n', 166 '#EOF\n',
166 '\n', 167 '\n',
167 'ActualHash: image_checksum-checksum\n', 168 'ActualHash: image_checksum-checksum\n',
168 'ExpectedHash: image_checksum-checksum\n', 169 'ExpectedHash: image_checksum-checksum\n',
169 '#EOF\n']) 170 '#EOF\n'])
170 171
171 def test_textonly(self): 172 def test_textonly(self):
172 self.assertTest('passes/image.html', False) 173 self.assertTest('passes/image.html', False)
173 174
174 def test_checksum_in_png(self): 175 def test_checksum_in_png(self):
175 self.assertTest('passes/checksum_in_image.html', True) 176 self.assertTest('passes/checksum_in_image.html', True)
176 177
177 def test_missing_image(self): 178 def test_missing_image(self):
178 self.assertTest('failures/expected/missing_image.html', True) 179 self.assertTest('failures/expected/missing_image.html', True)
179 180
180 def test_missing_text(self): 181 def test_missing_text(self):
181 self.assertTest('failures/expected/missing_text.html', True) 182 self.assertTest('failures/expected/missing_text.html', True)
182 183
183 def test_reftest_match(self): 184 def test_reftest_match(self):
184 self.assertTest('passes/reftest.html', True, expected_checksum='mock-che cksum', expected_text='reference text\n') 185 self.assertTest('passes/reftest.html', True, expected_checksum='mock-che cksum', expected_text='reference text\n')
185 186
186 def test_reftest_mismatch(self): 187 def test_reftest_mismatch(self):
187 self.assertTest('passes/mismatch.html', True, expected_checksum='mock-ch ecksum', expected_text='reference text\n') 188 self.assertTest('passes/mismatch.html', True, expected_checksum='mock-ch ecksum', expected_text='reference text\n')
188 189
189 def test_audio(self): 190 def test_audio(self):
190 self.assertTest('passes/audio.html', pixel_tests=True, 191 self.assertTest('passes/audio.html', pixel_tests=True,
191 drt_output=['Content-Type: audio/wav\n', 192 drt_output=['Content-Type: audio/wav\n',
192 'Content-Transfer-Encoding: base64\n', 193 'Content-Transfer-Encoding: base64\n',
193 'YXVkaW8td2F2', 194 'YXVkaW8td2F2',
194 '\n', 195 '\n',
195 '#EOF\n', 196 '#EOF\n',
196 '#EOF\n']) 197 '#EOF\n'])
197 198
198 def test_virtual(self): 199 def test_virtual(self):
199 self.assertTest('virtual/passes/text.html', True) 200 self.assertTest('virtual/passes/text.html', True)
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py ('k') | Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698