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

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

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/logcat_monitor.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 68c8b716f2f5dfac6819ab46b47cc38219c10dd7..6071fd57a069ebc625ca304c62ca0becf37a4e37 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -457,9 +457,17 @@ class DeviceUtilsRebootTest(DeviceUtilsNewImplTest):
self.call.adb.Reboot(),
(self.call.device.IsOnline(), True),
(self.call.device.IsOnline(), False),
- self.call.device.WaitUntilFullyBooted()):
+ self.call.device.WaitUntilFullyBooted(wifi=False)):
self.device.Reboot(block=True)
+ def testReboot_blockUntilWifi(self):
+ with self.assertCalls(
+ self.call.adb.Reboot(),
+ (self.call.device.IsOnline(), True),
+ (self.call.device.IsOnline(), False),
+ self.call.device.WaitUntilFullyBooted(wifi=True)):
+ self.device.Reboot(block=True, wifi=True)
+
class DeviceUtilsInstallTest(DeviceUtilsNewImplTest):
@@ -1230,81 +1238,44 @@ class DeviceUtilsStatTest(DeviceUtilsNewImplTest):
self.device.Stat('/data/local/tmp/does.not.exist.txt')
-class DeviceUtilsSetJavaAssertsTest(DeviceUtilsOldImplTest):
-
- @staticmethod
- def mockNamedTemporary(name='/tmp/file/property.file',
- read_contents=''):
- mock_file = mock.MagicMock(spec=file)
- mock_file.name = name
- mock_file.__enter__.return_value = mock_file
- mock_file.read.return_value = read_contents
- return mock_file
+class DeviceUtilsSetJavaAssertsTest(DeviceUtilsNewImplTest):
def testSetJavaAsserts_enable(self):
- mock_file = self.mockNamedTemporary()
- with mock.patch('tempfile.NamedTemporaryFile',
- return_value=mock_file), (
- mock.patch('__builtin__.open', return_value=mock_file)):
- with self.assertCallsSequence(
- [('adb -s 0123456789abcdef shell ls %s' %
- constants.DEVICE_LOCAL_PROPERTIES_PATH,
- '%s\r\n' % constants.DEVICE_LOCAL_PROPERTIES_PATH),
- ('adb -s 0123456789abcdef pull %s %s' %
- (constants.DEVICE_LOCAL_PROPERTIES_PATH, mock_file.name),
- '100 B/s (100 bytes in 1.000s)\r\n'),
- ('adb -s 0123456789abcdef push %s %s' %
- (mock_file.name, constants.DEVICE_LOCAL_PROPERTIES_PATH),
- '100 B/s (100 bytes in 1.000s)\r\n'),
- ('adb -s 0123456789abcdef shell '
- 'getprop dalvik.vm.enableassertions',
- '\r\n'),
- ('adb -s 0123456789abcdef shell '
- 'setprop dalvik.vm.enableassertions "all"',
- '')]):
- self.assertTrue(self.device.SetJavaAsserts(True))
+ with self.assertCalls(
+ (self.call.device.ReadFile(constants.DEVICE_LOCAL_PROPERTIES_PATH),
+ 'some.example.prop=with an example value\n'
+ 'some.other.prop=value_ok\n'),
+ self.call.device.WriteFile(
+ constants.DEVICE_LOCAL_PROPERTIES_PATH,
+ 'some.example.prop=with an example value\n'
+ 'some.other.prop=value_ok\n'
+ 'dalvik.vm.enableassertions=all\n'),
+ (self.call.device.GetProp('dalvik.vm.enableassertions'), ''),
+ self.call.device.SetProp('dalvik.vm.enableassertions', 'all')):
+ self.assertTrue(self.device.SetJavaAsserts(True))
def testSetJavaAsserts_disable(self):
- mock_file = self.mockNamedTemporary(
- read_contents='dalvik.vm.enableassertions=all\n')
- with mock.patch('tempfile.NamedTemporaryFile',
- return_value=mock_file), (
- mock.patch('__builtin__.open', return_value=mock_file)):
- with self.assertCallsSequence(
- [('adb -s 0123456789abcdef shell ls %s' %
- constants.DEVICE_LOCAL_PROPERTIES_PATH,
- '%s\r\n' % constants.DEVICE_LOCAL_PROPERTIES_PATH),
- ('adb -s 0123456789abcdef pull %s %s' %
- (constants.DEVICE_LOCAL_PROPERTIES_PATH, mock_file.name),
- '100 B/s (100 bytes in 1.000s)\r\n'),
- ('adb -s 0123456789abcdef push %s %s' %
- (mock_file.name, constants.DEVICE_LOCAL_PROPERTIES_PATH),
- '100 B/s (100 bytes in 1.000s)\r\n'),
- ('adb -s 0123456789abcdef shell '
- 'getprop dalvik.vm.enableassertions',
- 'all\r\n'),
- ('adb -s 0123456789abcdef shell '
- 'setprop dalvik.vm.enableassertions ""',
- '')]):
- self.assertTrue(self.device.SetJavaAsserts(False))
+ with self.assertCalls(
+ (self.call.device.ReadFile(constants.DEVICE_LOCAL_PROPERTIES_PATH),
+ 'some.example.prop=with an example value\n'
+ 'dalvik.vm.enableassertions=all\n'
+ 'some.other.prop=value_ok\n'),
+ self.call.device.WriteFile(
+ constants.DEVICE_LOCAL_PROPERTIES_PATH,
+ 'some.example.prop=with an example value\n'
+ 'some.other.prop=value_ok\n'),
+ (self.call.device.GetProp('dalvik.vm.enableassertions'), 'all'),
+ self.call.device.SetProp('dalvik.vm.enableassertions', '')):
+ self.assertTrue(self.device.SetJavaAsserts(False))
def testSetJavaAsserts_alreadyEnabled(self):
- mock_file = self.mockNamedTemporary(
- read_contents='dalvik.vm.enableassertions=all\n')
- with mock.patch('tempfile.NamedTemporaryFile',
- return_value=mock_file), (
- mock.patch('__builtin__.open', return_value=mock_file)):
- with self.assertCallsSequence(
- [('adb -s 0123456789abcdef shell ls %s' %
- constants.DEVICE_LOCAL_PROPERTIES_PATH,
- '%s\r\n' % constants.DEVICE_LOCAL_PROPERTIES_PATH),
- ('adb -s 0123456789abcdef pull %s %s' %
- (constants.DEVICE_LOCAL_PROPERTIES_PATH, mock_file.name),
- '100 B/s (100 bytes in 1.000s)\r\n'),
- ('adb -s 0123456789abcdef shell '
- 'getprop dalvik.vm.enableassertions',
- 'all\r\n')]):
- self.assertFalse(self.device.SetJavaAsserts(True))
+ with self.assertCalls(
+ (self.call.device.ReadFile(constants.DEVICE_LOCAL_PROPERTIES_PATH),
+ 'some.example.prop=with an example value\n'
+ 'dalvik.vm.enableassertions=all\n'
+ 'some.other.prop=value_ok\n'),
+ (self.call.device.GetProp('dalvik.vm.enableassertions'), 'all')):
+ self.assertFalse(self.device.SetJavaAsserts(True))
class DeviceUtilsGetPropTest(DeviceUtilsNewImplTest):
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | build/android/pylib/device/logcat_monitor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698