| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 import time | 30 import time |
| 31 import webkitpy.thirdparty.unittest2 as unittest | 31 import webkitpy.thirdparty.unittest2 as unittest |
| 32 | 32 |
| 33 from webkitpy.layout_tests.port.factory import PortFactory | 33 from webkitpy.layout_tests.port.factory import PortFactory |
| 34 from webkitpy.layout_tests.port import server_process | 34 from webkitpy.layout_tests.port import server_process |
| 35 from webkitpy.common.system.systemhost import SystemHost | 35 from webkitpy.common.system.systemhost import SystemHost |
| 36 from webkitpy.common.system.systemhost_mock import MockSystemHost | 36 from webkitpy.common.system.systemhost_mock import MockSystemHost |
| 37 from webkitpy.common.system.outputcapture import OutputCapture | 37 from webkitpy.common.system.outputcapture import OutputCapture |
| 38 | 38 |
| 39 | 39 |
| 40 | |
| 41 class TrivialMockPort(object): | 40 class TrivialMockPort(object): |
| 42 def __init__(self): | 41 def __init__(self): |
| 43 self.host = MockSystemHost() | 42 self.host = MockSystemHost() |
| 44 self.host.executive.kill_process = lambda x: None | 43 self.host.executive.kill_process = lambda x: None |
| 45 self.host.executive.kill_process = lambda x: None | 44 self.host.executive.kill_process = lambda x: None |
| 46 | 45 |
| 47 def results_directory(self): | 46 def results_directory(self): |
| 48 return "/mock-results" | 47 return "/mock-results" |
| 49 | 48 |
| 50 def process_kill_time(self): | 49 def process_kill_time(self): |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 self.assertIsNotNone(server_process.pid()) | 139 self.assertIsNotNone(server_process.pid()) |
| 141 self.assertIsNone(server_process._proc) | 140 self.assertIsNone(server_process._proc) |
| 142 self.assertEqual(server_process.broken_pipes, [server_process.stdin]) | 141 self.assertEqual(server_process.broken_pipes, [server_process.stdin]) |
| 143 | 142 |
| 144 port_obj.host.platform.os_name = 'mac' | 143 port_obj.host.platform.os_name = 'mac' |
| 145 server_process = FakeServerProcess(port_obj=port_obj, name="test", cmd=[
"test"]) | 144 server_process = FakeServerProcess(port_obj=port_obj, name="test", cmd=[
"test"]) |
| 146 server_process.write("should break") | 145 server_process.write("should break") |
| 147 self.assertTrue(server_process.has_crashed()) | 146 self.assertTrue(server_process.has_crashed()) |
| 148 self.assertIsNone(server_process._proc) | 147 self.assertIsNone(server_process._proc) |
| 149 self.assertEqual(server_process.broken_pipes, [server_process.stdin]) | 148 self.assertEqual(server_process.broken_pipes, [server_process.stdin]) |
| 149 |
| 150 |
| 151 class TestQuoteData(unittest.TestCase): |
| 152 def test_plain(self): |
| 153 qd = server_process.quote_data |
| 154 self.assertEqual(qd("foo"), ["foo"]) |
| 155 |
| 156 def test_trailing_spaces(self): |
| 157 qd = server_process.quote_data |
| 158 self.assertEqual(qd("foo "), |
| 159 ["foo\x20\x20"]) |
| 160 |
| 161 def test_newlines(self): |
| 162 qd = server_process.quote_data |
| 163 self.assertEqual(qd("foo \nbar\n"), |
| 164 ["foo\x20\\n", "bar\\n"]) |
| 165 |
| 166 def test_binary_data(self): |
| 167 qd = server_process.quote_data |
| 168 self.assertEqual(qd("\x00\x01ab"), |
| 169 ["\\x00\\x01ab"]) |
| OLD | NEW |