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

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

Issue 711113002: Add option to specify ADB binary in test runner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/adb_wrapper.py ('k') | build/android/test_runner.py » ('j') | 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if sys.exc_info()[0] is None: 173 if sys.exc_info()[0] is None:
174 on_failure_fmt = ('\n' 174 on_failure_fmt = ('\n'
175 ' received command: %s\n' 175 ' received command: %s\n'
176 ' expected command: %s') 176 ' expected command: %s')
177 self._test_case.assertGreater( 177 self._test_case.assertGreater(
178 len(self._cmds), self._total_received, 178 len(self._cmds), self._total_received,
179 msg=on_failure_fmt % (actual_cmd, None)) 179 msg=on_failure_fmt % (actual_cmd, None))
180 expected_cmd, ret = self._cmds[self._total_received] 180 expected_cmd, ret = self._cmds[self._total_received]
181 self._total_received += 1 181 self._total_received += 1
182 self._test_case.assertTrue( 182 self._test_case.assertTrue(
183 self._comp(expected_cmd, actual_cmd), 183 self._comp(expected_cmd, re.sub(r'/.*/adb', 'adb', actual_cmd)),
jbudorick 2014/11/17 23:01:07 I'm not a fan of this (even if these tests are gra
184 msg=on_failure_fmt % (actual_cmd, expected_cmd)) 184 msg=on_failure_fmt % (actual_cmd, expected_cmd))
185 return ret 185 return ret
186 return '' 186 return ''
187 187
188 def __exit__(self, exc_type, exc_val, exc_tb): 188 def __exit__(self, exc_type, exc_val, exc_tb):
189 self._run_command.patched.__exit__(exc_type, exc_val, exc_tb) 189 self._run_command.patched.__exit__(exc_type, exc_val, exc_tb)
190 if exc_type is None: 190 if exc_type is None:
191 on_failure = "adb commands don't match.\nExpected:%s\nActual:%s" % ( 191 on_failure = "adb commands don't match.\nExpected:%s\nActual:%s" % (
192 ''.join('\n %s' % c for c, _ in self._cmds), 192 ''.join('\n %s' % c for c, _ in self._cmds),
193 ''.join('\n %s' % a[0] 193 ''.join('\n %s' % a[0]
194 for _, a, kw in self._run_command.mocked.mock_calls)) 194 for _, a, kw in self._run_command.mocked.mock_calls))
195 self._test_case.assertEqual( 195 self._test_case.assertEqual(
196 len(self._cmds), len(self._run_command.mocked.mock_calls), 196 len(self._cmds), len(self._run_command.mocked.mock_calls),
197 msg=on_failure) 197 msg=on_failure)
198 for (expected_cmd, _r), (_n, actual_args, actual_kwargs) in zip( 198 for (expected_cmd, _r), (_n, actual_args, actual_kwargs) in zip(
199 self._cmds, self._run_command.mocked.mock_calls): 199 self._cmds, self._run_command.mocked.mock_calls):
200 self._test_case.assertEqual(1, len(actual_args), msg=on_failure) 200 self._test_case.assertEqual(1, len(actual_args), msg=on_failure)
201 self._test_case.assertTrue(self._comp(expected_cmd, actual_args[0]), 201 self._test_case.assertTrue(self._comp(expected_cmd,
202 msg=on_failure) 202 re.sub(r'/.*/adb', 'adb', actual_args[0])), msg=on_failure)
203 self._test_case.assertTrue('timeout_time' in actual_kwargs, 203 self._test_case.assertTrue('timeout_time' in actual_kwargs,
204 msg=on_failure) 204 msg=on_failure)
205 self._test_case.assertTrue('retry_count' in actual_kwargs, 205 self._test_case.assertTrue('retry_count' in actual_kwargs,
206 msg=on_failure) 206 msg=on_failure)
207 207
208 def assertNoAdbCalls(self): 208 def assertNoAdbCalls(self):
209 return type(self).AndroidCommandsCalls(self, [], str.__eq__) 209 return type(self).AndroidCommandsCalls(self, [], str.__eq__)
210 210
211 def assertCalls(self, cmd, ret, comp=str.__eq__): 211 def assertCalls(self, cmd, ret, comp=str.__eq__):
212 return type(self).AndroidCommandsCalls(self, [(cmd, ret)], comp) 212 return type(self).AndroidCommandsCalls(self, [(cmd, ret)], comp)
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 self.device = device_utils.DeviceUtils(None) 1624 self.device = device_utils.DeviceUtils(None)
1625 with self.assertCalls('adb get-serialno', 'unknown'), ( 1625 with self.assertCalls('adb get-serialno', 'unknown'), (
1626 self.assertRaises(device_errors.NoDevicesError)): 1626 self.assertRaises(device_errors.NoDevicesError)):
1627 str(self.device) 1627 str(self.device)
1628 1628
1629 1629
1630 if __name__ == '__main__': 1630 if __name__ == '__main__':
1631 logging.getLogger().setLevel(logging.DEBUG) 1631 logging.getLogger().setLevel(logging.DEBUG)
1632 unittest.main(verbosity=2) 1632 unittest.main(verbosity=2)
1633 1633
OLDNEW
« no previous file with comments | « build/android/pylib/device/adb_wrapper.py ('k') | build/android/test_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698