| OLD | NEW |
| 1 # Copyright (C) 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2012 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 24 matching lines...) Expand all Loading... |
| 35 from webkitpy.common.system import executive_mock | 35 from webkitpy.common.system import executive_mock |
| 36 from webkitpy.common.system.executive_mock import MockExecutive2 | 36 from webkitpy.common.system.executive_mock import MockExecutive2 |
| 37 from webkitpy.common.system.systemhost_mock import MockSystemHost | 37 from webkitpy.common.system.systemhost_mock import MockSystemHost |
| 38 | 38 |
| 39 from webkitpy.layout_tests.port import chromium_android | 39 from webkitpy.layout_tests.port import chromium_android |
| 40 from webkitpy.layout_tests.port import chromium_port_testcase | 40 from webkitpy.layout_tests.port import chromium_port_testcase |
| 41 from webkitpy.layout_tests.port import driver | 41 from webkitpy.layout_tests.port import driver |
| 42 from webkitpy.layout_tests.port import driver_unittest | 42 from webkitpy.layout_tests.port import driver_unittest |
| 43 from webkitpy.tool.mocktool import MockOptions | 43 from webkitpy.tool.mocktool import MockOptions |
| 44 | 44 |
| 45 |
| 45 # Any "adb" commands will be interpret by this class instead of executing actual | 46 # Any "adb" commands will be interpret by this class instead of executing actual |
| 46 # commansd on the file system, which we don't want to do. | 47 # commansd on the file system, which we don't want to do. |
| 47 class MockAndroidDebugBridge: | 48 class MockAndroidDebugBridge: |
| 48 def __init__(self, device_count): | 49 def __init__(self, device_count): |
| 49 self._device_count = device_count | 50 self._device_count = device_count |
| 50 self._last_command = None | 51 self._last_command = None |
| 51 | 52 |
| 52 # Local public methods. | 53 # Local public methods. |
| 53 | 54 |
| 54 def run_command(self, args): | 55 def run_command(self, args): |
| (...skipping 21 matching lines...) Expand all Loading... |
| 76 def last_command(self): | 77 def last_command(self): |
| 77 return self._last_command | 78 return self._last_command |
| 78 | 79 |
| 79 # Local private methods. | 80 # Local private methods. |
| 80 | 81 |
| 81 def _get_device_output(self): | 82 def _get_device_output(self): |
| 82 serials = ['123456789ABCDEF0', '123456789ABCDEF1', '123456789ABCDEF2', | 83 serials = ['123456789ABCDEF0', '123456789ABCDEF1', '123456789ABCDEF2', |
| 83 '123456789ABCDEF3', '123456789ABCDEF4', '123456789ABCDEF5'] | 84 '123456789ABCDEF3', '123456789ABCDEF4', '123456789ABCDEF5'] |
| 84 output = 'List of devices attached\n' | 85 output = 'List of devices attached\n' |
| 85 for serial in serials[:self._device_count]: | 86 for serial in serials[:self._device_count]: |
| 86 output += '%s\tdevice\n' % serial | 87 output += '%s\tdevice\n' % serial |
| 87 return output | 88 return output |
| 88 | 89 |
| 89 | 90 |
| 90 class AndroidCommandsTest(unittest.TestCase): | 91 class AndroidCommandsTest(unittest.TestCase): |
| 91 def setUp(self): | 92 def setUp(self): |
| 92 chromium_android.AndroidCommands._adb_command_path = None | 93 chromium_android.AndroidCommands._adb_command_path = None |
| 93 chromium_android.AndroidCommands._adb_command_path_options = ['adb'] | 94 chromium_android.AndroidCommands._adb_command_path_options = ['adb'] |
| 94 | 95 |
| 95 def make_executive(self, device_count): | 96 def make_executive(self, device_count): |
| 96 self._mock_executive = MockAndroidDebugBridge(device_count) | 97 self._mock_executive = MockAndroidDebugBridge(device_count) |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 mock_adb = MockAndroidDebugBridge(2) | 211 mock_adb = MockAndroidDebugBridge(2) |
| 211 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command) | 212 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command) |
| 212 | 213 |
| 213 port0 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo
ck_executive), | 214 port0 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo
ck_executive), |
| 214 'chromium-android', options=MockOptions(additional_drt_flag=['--foo=
bar'])) | 215 'chromium-android', options=MockOptions(additional_drt_flag=['--foo=
bar'])) |
| 215 port1 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo
ck_executive), | 216 port1 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo
ck_executive), |
| 216 'chromium-android', options=MockOptions(driver_name='content_shell')
) | 217 'chromium-android', options=MockOptions(driver_name='content_shell')
) |
| 217 | 218 |
| 218 self.assertEqual(1, port0.driver_cmd_line().count('--foo=bar')) | 219 self.assertEqual(1, port0.driver_cmd_line().count('--foo=bar')) |
| 219 self.assertEqual(0, port1.driver_cmd_line().count('--create-stdin-fifo')
) | 220 self.assertEqual(0, port1.driver_cmd_line().count('--create-stdin-fifo')
) |
| 220 | |
| 221 | |
| 222 class ChromiumAndroidTwoPortsTest(unittest.TestCase): | |
| 223 # Test that the driver's command line indeed goes through to the driver. | |
| 224 def test_options_with_two_ports(self): | |
| 225 mock_adb = MockAndroidDebugBridge(2) | |
| 226 mock_executive = MockExecutive2(run_command_fn=mock_adb.run_command) | |
| 227 | |
| 228 port0 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo
ck_executive), | |
| 229 'chromium-android', options=MockOptions(additional_drt_flag=['--foo=
bar'])) | |
| 230 port1 = chromium_android.ChromiumAndroidPort(MockSystemHost(executive=mo
ck_executive), | |
| 231 'chromium-android', options=MockOptions(driver_name='content_shell')
) | |
| 232 | |
| 233 self.assertEqual(1, port0.driver_cmd_line().count('--foo=bar')) | |
| 234 self.assertEqual(0, port1.driver_cmd_line().count('--create-stdin-fifo')
) | |
| OLD | NEW |