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

Unified Diff: build/android/pylib/device/device_utils_test.py

Issue 762883002: Make device serial required in AdbWrapper/DeviceUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renamed: exclude -> ignore 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | build/android/pylib/instrumentation/test_runner_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/device/device_utils_test.py
diff --git a/build/android/pylib/device/device_utils_test.py b/build/android/pylib/device/device_utils_test.py
index 4f47021e2dcb7ba66cc02c45f68dc3ac9597289e..55fe60125d0732fef87b7516dad0a8a135fe63bc 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -43,28 +43,30 @@ class DeviceUtilsTest(unittest.TestCase):
def testInitWithStr(self):
serial_as_str = str('0123456789abcdef')
d = device_utils.DeviceUtils('0123456789abcdef')
- self.assertEqual(serial_as_str, d.old_interface.GetDevice())
+ self.assertEqual(serial_as_str, d.adb.GetDeviceSerial())
def testInitWithUnicode(self):
serial_as_unicode = unicode('fedcba9876543210')
d = device_utils.DeviceUtils(serial_as_unicode)
- self.assertEqual(serial_as_unicode, d.old_interface.GetDevice())
+ self.assertEqual(serial_as_unicode, d.adb.GetDeviceSerial())
def testInitWithAdbWrapper(self):
serial = '123456789abcdef0'
a = adb_wrapper.AdbWrapper(serial)
d = device_utils.DeviceUtils(a)
- self.assertEqual(serial, d.old_interface.GetDevice())
+ self.assertEqual(serial, d.adb.GetDeviceSerial())
def testInitWithAndroidCommands(self):
serial = '0fedcba987654321'
a = android_commands.AndroidCommands(device=serial)
d = device_utils.DeviceUtils(a)
- self.assertEqual(serial, d.old_interface.GetDevice())
+ self.assertEqual(serial, d.adb.GetDeviceSerial())
- def testInitWithNone(self):
- d = device_utils.DeviceUtils(None)
- self.assertIsNone(d.old_interface.GetDevice())
+ def testInitWithMissing_fails(self):
+ with self.assertRaises(ValueError):
+ device_utils.DeviceUtils(None)
+ with self.assertRaises(ValueError):
+ device_utils.DeviceUtils('')
class MockTempFile(object):
@@ -246,7 +248,7 @@ class DeviceUtilsNewImplTest(mock_calls.TestCase):
self.adb.GetDeviceSerial.return_value = test_serial
self.device = device_utils.DeviceUtils(
self.adb, default_timeout=10, default_retries=0)
- self.watchMethodCalls(self.call.adb)
+ self.watchMethodCalls(self.call.adb, ignore=['GetDeviceSerial'])
def ShellError(self, output=None, exit_code=1):
def action(cmd, *args, **kwargs):
@@ -1552,23 +1554,13 @@ class DeviceUtilsGetMemoryUsageForPidTest(DeviceUtilsOldImplTest):
self.assertEqual({}, self.device.GetMemoryUsageForPid(4321))
-class DeviceUtilsStrTest(DeviceUtilsOldImplTest):
+class DeviceUtilsStrTest(DeviceUtilsNewImplTest):
- def testStr_noAdbCalls(self):
- with self.assertNoAdbCalls():
- self.assertEqual('0123456789abcdef', str(self.device))
-
- def testStr_noSerial(self):
- self.device = device_utils.DeviceUtils(None)
- with self.assertCalls('adb get-serialno', '0123456789abcdef'):
+ def testStr_returnsSerial(self):
+ with self.assertCalls(
+ (self.call.adb.GetDeviceSerial(), '0123456789abcdef')):
self.assertEqual('0123456789abcdef', str(self.device))
- def testStr_noSerial_noDevices(self):
- self.device = device_utils.DeviceUtils(None)
- with self.assertCalls('adb get-serialno', 'unknown'), (
- self.assertRaises(device_errors.NoDevicesError)):
- str(self.device)
-
if __name__ == '__main__':
logging.getLogger().setLevel(logging.DEBUG)
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | build/android/pylib/instrumentation/test_runner_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698