| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 """Tests for the AdbWrapper class.""" | 5 """Tests for the AdbWrapper class.""" |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import tempfile | 8 import tempfile |
| 9 import time | 9 import time |
| 10 import unittest | 10 import unittest |
| 11 | 11 |
| 12 from pylib.device import adb_wrapper | 12 from pylib.device import adb_wrapper |
| 13 | 13 |
| 14 | 14 |
| 15 class TestAdbWrapper(unittest.TestCase): | 15 class TestAdbWrapper(unittest.TestCase): |
| 16 | 16 |
| 17 def setUp(self): | 17 def setUp(self): |
| 18 devices = adb_wrapper.AdbWrapper.GetDevices() | 18 devices = adb_wrapper.AdbWrapper.GetDevices() |
| 19 assert devices, 'A device must be attached' | 19 assert devices, 'A device must be attached' |
| 20 self._adb = devices[0] | 20 self._adb = devices[0] |
| 21 self._adb.WaitForDevice() | 21 self._adb.WaitForDevice() |
| 22 | 22 |
| 23 @staticmethod | 23 @staticmethod |
| 24 def _MakeTempFile(contents): | 24 def _MakeTempFile(contents): |
| 25 """Make a temporary file with the given contents. | 25 """Make a temporary file with the given contents. |
| 26 | 26 |
| 27 Args: | 27 Args: |
| 28 contents: string to write to the temporary file. | 28 contents: string to write to the temporary file. |
| 29 | 29 |
| 30 Returns: | 30 Returns: |
| 31 The absolute path to the file. | 31 The absolute path to the file. |
| 32 """ | 32 """ |
| 33 fi, path = tempfile.mkstemp() | 33 fi, path = tempfile.mkstemp() |
| 34 with os.fdopen(fi, 'wb') as f: | 34 with os.fdopen(fi, 'wb') as f: |
| 35 f.write(contents) | 35 f.write(contents) |
| 36 return path | 36 return path |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 try: | 81 try: |
| 82 self._adb.Shell('start') | 82 self._adb.Shell('start') |
| 83 break | 83 break |
| 84 except adb_wrapper.CommandFailedError: | 84 except adb_wrapper.CommandFailedError: |
| 85 time.sleep(1) | 85 time.sleep(1) |
| 86 self._adb.Remount() | 86 self._adb.Remount() |
| 87 | 87 |
| 88 | 88 |
| 89 if __name__ == '__main__': | 89 if __name__ == '__main__': |
| 90 unittest.main() | 90 unittest.main() |
| OLD | NEW |