def test_read_stdin_path(self): port = TestWebKitPort() driver = browser_test_driver.BrowserTestDriver(port, 0, pixel_tests=True) driver._server_process = MockServerProcess(lines=[ 'StdinPath: /foo/bar', '#EOF']) content_block = driver._read_block(0) self.assertEqual(content_block.stdin_path, '/foo/bar') driver._stdin_directory = None
def test_read_block(self): port = TestWebKitPort() driver = Driver(port, 0, pixel_tests=False) driver._server_process = MockServerProcess(lines=[ 'ActualHash: foobar', 'Content-Type: my_type', 'Content-Transfer-Encoding: none', "#EOF", ]) content_block = driver._read_block(0) self.assertEqual(content_block.content_type, 'my_type') self.assertEqual(content_block.encoding, 'none') self.assertEqual(content_block.content_hash, 'foobar') driver._server_process = None
def test_read_binary_block(self): port = TestWebKitPort() driver = Driver(port, 0, pixel_tests=True) driver._server_process = MockServerProcess(lines=[ 'ActualHash: actual', 'ExpectedHash: expected', 'Content-Type: image/png', 'Content-Length: 9', "12345678", "#EOF", ]) content_block = driver._read_block(0) self.assertEqual(content_block.content_type, 'image/png') self.assertEqual(content_block.content_hash, 'actual') self.assertEqual(content_block.content, '12345678\n') self.assertEqual(content_block.decoded_content, '12345678\n') driver._server_process = None
def test_read_base64_block(self): port = TestWebKitPort() driver = Driver(port, 0, pixel_tests=True) driver._server_process = MockServerProcess(lines=[ 'ActualHash: actual', 'ExpectedHash: expected', 'Content-Type: image/png', 'Content-Transfer-Encoding: base64', 'Content-Length: 12', 'MTIzNDU2NzgK#EOF', ]) content_block = driver._read_block(0) self.assertEqual(content_block.content_type, 'image/png') self.assertEqual(content_block.content_hash, 'actual') self.assertEqual(content_block.encoding, 'base64') self.assertEqual(content_block.content, 'MTIzNDU2NzgK') self.assertEqual(content_block.decoded_content, '12345678\n')
def __init__(self, server_process_output): self._server_process_constructor = lambda port, nm, cmd, env: MockServerProcess( lines=server_process_output)