Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: build/android/pylib/device/device_utils_test.py

Issue 724413003: Migrate device_utils.RestartServer to adb_wrapper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased against master Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ 6 """
7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils).
8 """ 8 """
9 9
10 # pylint: disable=C0321 10 # pylint: disable=C0321
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 'Available Android Virtual Devices:\n' 77 'Available Android Virtual Devices:\n'
78 ' Name: my_android5.0\n' 78 ' Name: my_android5.0\n'
79 ' Path: /some/path/to/.android/avd/my_android5.0.avd\n' 79 ' Path: /some/path/to/.android/avd/my_android5.0.avd\n'
80 ' Target: Android 5.0 (API level 21)\n' 80 ' Target: Android 5.0 (API level 21)\n'
81 ' Tag/ABI: default/x86\n' 81 ' Tag/ABI: default/x86\n'
82 ' Skin: WVGA800\n'): 82 ' Skin: WVGA800\n'):
83 self.assertEquals(['my_android5.0'], 83 self.assertEquals(['my_android5.0'],
84 device_utils.GetAVDs()) 84 device_utils.GetAVDs())
85 85
86 86
87 class DeviceUtilsRestartServerTest(mock_calls.TestCase):
88
89 @mock.patch('time.sleep', mock.Mock())
90 def testRestartServer_succeeds(self):
91 with self.assertCalls(
92 mock.call.pylib.device.adb_wrapper.AdbWrapper.KillServer(),
93 (mock.call.pylib.cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb']),
94 (1, '')),
95 mock.call.pylib.device.adb_wrapper.AdbWrapper.StartServer(),
96 (mock.call.pylib.cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb']),
97 (1, '')),
98 (mock.call.pylib.cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb']),
99 (0, '123\n'))):
100 device_utils.RestartServer()
101
102
87 class MockTempFile(object): 103 class MockTempFile(object):
88 104
89 def __init__(self, name='/tmp/some/file'): 105 def __init__(self, name='/tmp/some/file'):
90 self.file = mock.MagicMock(spec=file) 106 self.file = mock.MagicMock(spec=file)
91 self.file.name = name 107 self.file.name = name
92 108
93 def __enter__(self): 109 def __enter__(self):
94 return self.file 110 return self.file
95 111
96 def __exit__(self, exc_type, exc_val, exc_tb): 112 def __exit__(self, exc_type, exc_val, exc_tb):
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 self.assertTrue( 1557 self.assertTrue(
1542 isinstance(device, device_utils.DeviceUtils) 1558 isinstance(device, device_utils.DeviceUtils)
1543 and serial == str(device), 1559 and serial == str(device),
1544 'Expected a DeviceUtils object with serial %s' % serial) 1560 'Expected a DeviceUtils object with serial %s' % serial)
1545 1561
1546 1562
1547 if __name__ == '__main__': 1563 if __name__ == '__main__':
1548 logging.getLogger().setLevel(logging.DEBUG) 1564 logging.getLogger().setLevel(logging.DEBUG)
1549 unittest.main(verbosity=2) 1565 unittest.main(verbosity=2)
1550 1566
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698