OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Provides an interface to communicate with the device via the adb command. | 5 """Provides an interface to communicate with the device via the adb command. |
6 | 6 |
7 Assumes adb binary is currently on system path. | 7 Assumes adb binary is currently on system path. |
8 """ | 8 """ |
9 # pylint: disable-all | 9 # pylint: disable-all |
10 | 10 |
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 raise device_errors.AdbCommandFailedError( | 1795 raise device_errors.AdbCommandFailedError( |
1796 ['pull', device_file, host_file], 'Failed to pull file from device.') | 1796 ['pull', device_file, host_file], 'Failed to pull file from device.') |
1797 assert os.path.exists(host_file) | 1797 assert os.path.exists(host_file) |
1798 | 1798 |
1799 def SetUtilWrapper(self, util_wrapper): | 1799 def SetUtilWrapper(self, util_wrapper): |
1800 """Sets a wrapper prefix to be used when running a locally-built | 1800 """Sets a wrapper prefix to be used when running a locally-built |
1801 binary on the device (ex.: md5sum_bin). | 1801 binary on the device (ex.: md5sum_bin). |
1802 """ | 1802 """ |
1803 self._util_wrapper = util_wrapper | 1803 self._util_wrapper = util_wrapper |
1804 | 1804 |
1805 def RunInstrumentationTest(self, test, test_package, instr_args, timeout): | |
1806 """Runs a single instrumentation test. | |
1807 | |
1808 Args: | |
1809 test: Test class/method. | |
1810 test_package: Package name of test apk. | |
1811 instr_args: Extra key/value to pass to am instrument. | |
1812 timeout: Timeout time in seconds. | |
1813 | |
1814 Returns: | |
1815 An instance of am_instrument_parser.TestResult object. | |
1816 """ | |
1817 instrumentation_path = ('%s/android.test.InstrumentationTestRunner' % | |
1818 test_package) | |
1819 args_with_filter = dict(instr_args) | |
1820 args_with_filter['class'] = test | |
1821 logging.info(args_with_filter) | |
1822 (raw_results, _) = self._adb.StartInstrumentation( | |
1823 instrumentation_path=instrumentation_path, | |
1824 instrumentation_args=args_with_filter, | |
1825 timeout_time=timeout) | |
1826 assert len(raw_results) == 1 | |
1827 return raw_results[0] | |
1828 | |
1829 def RunUIAutomatorTest(self, test, test_package, timeout): | 1805 def RunUIAutomatorTest(self, test, test_package, timeout): |
1830 """Runs a single uiautomator test. | 1806 """Runs a single uiautomator test. |
1831 | 1807 |
1832 Args: | 1808 Args: |
1833 test: Test class/method. | 1809 test: Test class/method. |
1834 test_package: Name of the test jar. | 1810 test_package: Name of the test jar. |
1835 timeout: Timeout time in seconds. | 1811 timeout: Timeout time in seconds. |
1836 | 1812 |
1837 Returns: | 1813 Returns: |
1838 An instance of am_instrument_parser.TestResult object. | 1814 An instance of am_instrument_parser.TestResult object. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 """ | 1952 """ |
1977 def __init__(self, output): | 1953 def __init__(self, output): |
1978 self._output = output | 1954 self._output = output |
1979 | 1955 |
1980 def write(self, data): | 1956 def write(self, data): |
1981 data = data.replace('\r\r\n', '\n') | 1957 data = data.replace('\r\r\n', '\n') |
1982 self._output.write(data) | 1958 self._output.write(data) |
1983 | 1959 |
1984 def flush(self): | 1960 def flush(self): |
1985 self._output.flush() | 1961 self._output.flush() |
OLD | NEW |