| Index: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py
|
| index 9b6a25e55f438b7eb52381d4a3d731e2a2cf9052..9b96ae6bcf4cd0556fe96149d4518a1736d3cbcd 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py
|
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/linux_unittest.py
|
| @@ -116,22 +116,37 @@ class LinuxPortTest(port_testcase.PortTestCase):
|
| self.assertFalse(port.host.filesystem.exists(temp_home_dir))
|
|
|
| def test_setup_test_run_starts_xvfb(self):
|
| + def run_command_fake(args):
|
| + if args[0] == 'xdpyinfo':
|
| + if '-display' in args:
|
| + return 1
|
| + return 0
|
| +
|
| port = self.make_port()
|
| - port.host.executive = MockExecutive(exit_code=1)
|
| + port.host.executive = MockExecutive(
|
| + run_command_fn=run_command_fake)
|
| port.setup_test_run()
|
| self.assertEqual(
|
| port.host.executive.calls,
|
| [
|
| ['xdpyinfo', '-display', ':99'],
|
| ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '96'],
|
| + ['xdpyinfo'],
|
| ])
|
| env = port.setup_environ_for_server()
|
| self.assertEqual(env['DISPLAY'], ':99')
|
|
|
| def test_setup_test_runs_finds_free_display(self):
|
| + def run_command_fake(args):
|
| + if args[0] == 'xdpyinfo':
|
| + if '-display' in args:
|
| + if ':102' in args:
|
| + return 1
|
| + return 0
|
| +
|
| port = self.make_port()
|
| port.host.executive = MockExecutive(
|
| - run_command_fn=lambda args: 1 if ':102' in args else 0)
|
| + run_command_fn=run_command_fake)
|
| port.setup_test_run()
|
| self.assertEqual(
|
| port.host.executive.calls,
|
| @@ -141,6 +156,56 @@ class LinuxPortTest(port_testcase.PortTestCase):
|
| ['xdpyinfo', '-display', ':101'],
|
| ['xdpyinfo', '-display', ':102'],
|
| ['Xvfb', ':102', '-screen', '0', '1280x800x24', '-ac', '-dpi', '96'],
|
| + ['xdpyinfo'],
|
| ])
|
| env = port.setup_environ_for_server()
|
| self.assertEqual(env['DISPLAY'], ':102')
|
| +
|
| + def test_setup_test_runs_multiple_checks_when_slow_to_start(self):
|
| + count = [0]
|
| +
|
| + def run_command_fake(args):
|
| + if args[0] == 'xdpyinfo':
|
| + if '-display' in args:
|
| + return 1
|
| + if count[0] < 3:
|
| + count[0] += 1
|
| + return 1
|
| + return 0
|
| +
|
| + port = self.make_port()
|
| + port.host.executive = MockExecutive(
|
| + run_command_fn=run_command_fake)
|
| + port.setup_test_run()
|
| + self.assertEqual(
|
| + port.host.executive.calls,
|
| + [
|
| + ['xdpyinfo', '-display', ':99'],
|
| + ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '96'],
|
| + ['xdpyinfo'],
|
| + ['xdpyinfo'],
|
| + ['xdpyinfo'],
|
| + ['xdpyinfo'],
|
| + ])
|
| + env = port.setup_environ_for_server()
|
| + self.assertEqual(env['DISPLAY'], ':99')
|
| +
|
| + def test_setup_test_runs_eventually_failes_on_failure(self):
|
| + def run_command_fake(args):
|
| + if args[0] == 'xdpyinfo':
|
| + return 1
|
| + return 0
|
| +
|
| + host = MockSystemHost(os_name=self.os_name, os_version=self.os_version)
|
| + port = self.make_port(host=host)
|
| + port.host.executive = MockExecutive(
|
| + run_command_fn=run_command_fake)
|
| + port.setup_test_run()
|
| + self.assertEqual(
|
| + port.host.executive.calls,
|
| + [
|
| + ['xdpyinfo', '-display', ':99'],
|
| + ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '96'],
|
| + ] + [['xdpyinfo']] * 51)
|
| + env = port.setup_environ_for_server()
|
| + self.assertEqual(env['DISPLAY'], ':99')
|
|
|