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 4301e9d9a5efe497fd12ce4e3bb1e5af6e34bf4c..e5e39360366ca58f89629852473bcb6bba65df3d 100755 |
--- a/build/android/pylib/device/device_utils_test.py |
+++ b/build/android/pylib/device/device_utils_test.py |
@@ -161,6 +161,73 @@ class DeviceUtilsTest(mock_calls.TestCase): |
msg, str(self.device))) |
+class DeviceUtilsEqTest(DeviceUtilsTest): |
+ |
+ def testEq_equal_deviceUtils(self): |
+ other = device_utils.DeviceUtils(_AdbWrapperMock('0123456789abcdef')) |
+ self.assertTrue(self.device == other) |
+ self.assertTrue(other == self.device) |
+ |
+ def testEq_equal_adbWrapper(self): |
+ other = adb_wrapper.AdbWrapper('0123456789abcdef') |
+ self.assertTrue(self.device == other) |
+ self.assertTrue(other == self.device) |
+ |
+ def testEq_equal_string(self): |
+ other = '0123456789abcdef' |
+ self.assertTrue(self.device == other) |
+ self.assertTrue(other == self.device) |
+ |
+ def testEq_devicesNotEqual(self): |
+ other = device_utils.DeviceUtils(_AdbWrapperMock('0123456789abcdee')) |
+ self.assertFalse(self.device == other) |
+ self.assertFalse(other == self.device) |
+ |
+ def testEq_identity(self): |
+ self.assertTrue(self.device == self.device) |
+ |
+ def testEq_serialInList(self): |
+ devices = [self.device] |
+ self.assertTrue('0123456789abcdef' in devices) |
+ |
+ |
+class DeviceUtilsLtTest(DeviceUtilsTest): |
+ |
+ def testLt_lessThan(self): |
+ other = device_utils.DeviceUtils(_AdbWrapperMock('ffffffffffffffff')) |
+ self.assertTrue(self.device < other) |
+ self.assertTrue(other > self.device) |
+ |
+ def testLt_greaterThan_lhs(self): |
+ other = device_utils.DeviceUtils(_AdbWrapperMock('0000000000000000')) |
+ self.assertFalse(self.device < other) |
+ self.assertFalse(other > self.device) |
+ |
+ def testLt_equal(self): |
+ other = device_utils.DeviceUtils(_AdbWrapperMock('0123456789abcdef')) |
+ self.assertFalse(self.device < other) |
+ self.assertFalse(other > self.device) |
+ |
+ def testLt_sorted(self): |
+ devices = [ |
+ device_utils.DeviceUtils(_AdbWrapperMock('ffffffffffffffff')), |
+ device_utils.DeviceUtils(_AdbWrapperMock('0000000000000000')), |
+ ] |
+ sorted_devices = sorted(devices) |
+ self.assertEquals('0000000000000000', |
+ sorted_devices[0].adb.GetDeviceSerial()) |
+ self.assertEquals('ffffffffffffffff', |
+ sorted_devices[1].adb.GetDeviceSerial()) |
+ |
+ |
+class DeviceUtilsStrTest(DeviceUtilsTest): |
+ |
+ def testStr_returnsSerial(self): |
+ with self.assertCalls( |
+ (self.call.adb.GetDeviceSerial(), '0123456789abcdef')): |
+ self.assertEqual('0123456789abcdef', str(self.device)) |
+ |
+ |
class DeviceUtilsIsOnlineTest(DeviceUtilsTest): |
def testIsOnline_true(self): |
@@ -594,7 +661,8 @@ class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): |
(mock.call.pylib.utils.device_temp_file.DeviceTempFile(self.adb), |
temp_file), |
(self.call.adb.Shell(cmd_redirect)), |
- (self.call.device.ReadFile(temp_file.name), 'something')): |
+ (self.call.device.ReadFile(temp_file.name, force_pull=True), |
+ 'something')): |
self.assertEquals( |
['something'], |
self.device.RunShellCommand( |
@@ -615,7 +683,8 @@ class DeviceUtilsRunShellCommandTest(DeviceUtilsTest): |
(mock.call.pylib.utils.device_temp_file.DeviceTempFile(self.adb), |
temp_file), |
(self.call.adb.Shell(cmd_redirect)), |
- (self.call.device.ReadFile(mock.ANY), 'something')): |
+ (self.call.device.ReadFile(mock.ANY, force_pull=True), |
+ 'something')): |
self.assertEquals(['something'], |
self.device.RunShellCommand(cmd, check_return=True)) |
@@ -1223,6 +1292,15 @@ class DeviceUtilsReadFileTest(DeviceUtilsTest): |
self.device.ReadFile('/this/big/file/can.be.read.with.su', |
as_root=True)) |
+ def testReadFile_forcePull(self): |
+ contents = 'a' * 123456 |
+ with self.assertCall( |
+ self.call.device._ReadFileWithPull('/read/this/big/test/file'), |
+ contents): |
+ self.assertEqual( |
+ contents, |
+ self.device.ReadFile('/read/this/big/test/file', force_pull=True)) |
+ |
class DeviceUtilsWriteFileTest(DeviceUtilsTest): |
@@ -1539,14 +1617,6 @@ class DeviceUtilsGetMemoryUsageForPidTest(DeviceUtilsTest): |
self.device.GetMemoryUsageForPid(4321)) |
-class DeviceUtilsStrTest(DeviceUtilsTest): |
- |
- def testStr_returnsSerial(self): |
- with self.assertCalls( |
- (self.call.adb.GetDeviceSerial(), '0123456789abcdef')): |
- self.assertEqual('0123456789abcdef', str(self.device)) |
- |
- |
class DeviceUtilsClientCache(DeviceUtilsTest): |
def testClientCache_twoCaches(self): |