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

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

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months 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/device/shared_prefs.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 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):
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | build/android/pylib/device/shared_prefs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698