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

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

Issue 602973004: [Android] Make SetJavaAsserts return True if a restart is required. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | no next file » | 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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 '100 B/s (100 bytes in 1.000s)\r\n'), 1305 '100 B/s (100 bytes in 1.000s)\r\n'),
1306 ('adb -s 0123456789abcdef push %s %s' % 1306 ('adb -s 0123456789abcdef push %s %s' %
1307 (mock_file.name, constants.DEVICE_LOCAL_PROPERTIES_PATH), 1307 (mock_file.name, constants.DEVICE_LOCAL_PROPERTIES_PATH),
1308 '100 B/s (100 bytes in 1.000s)\r\n'), 1308 '100 B/s (100 bytes in 1.000s)\r\n'),
1309 ('adb -s 0123456789abcdef shell ' 1309 ('adb -s 0123456789abcdef shell '
1310 'getprop dalvik.vm.enableassertions', 1310 'getprop dalvik.vm.enableassertions',
1311 '\r\n'), 1311 '\r\n'),
1312 ('adb -s 0123456789abcdef shell ' 1312 ('adb -s 0123456789abcdef shell '
1313 'setprop dalvik.vm.enableassertions "all"', 1313 'setprop dalvik.vm.enableassertions "all"',
1314 '')]): 1314 '')]):
1315 self.device.SetJavaAsserts(True) 1315 self.assertTrue(self.device.SetJavaAsserts(True))
1316 1316
1317 def testSetJavaAsserts_disable(self): 1317 def testSetJavaAsserts_disable(self):
1318 mock_file = self.mockNamedTemporary( 1318 mock_file = self.mockNamedTemporary(
1319 read_contents='dalvik.vm.enableassertions=all\n') 1319 read_contents='dalvik.vm.enableassertions=all\n')
1320 with mock.patch('tempfile.NamedTemporaryFile', 1320 with mock.patch('tempfile.NamedTemporaryFile',
1321 return_value=mock_file), ( 1321 return_value=mock_file), (
1322 mock.patch('__builtin__.open', return_value=mock_file)): 1322 mock.patch('__builtin__.open', return_value=mock_file)):
1323 with self.assertCallsSequence( 1323 with self.assertCallsSequence(
1324 [('adb -s 0123456789abcdef shell ls %s' % 1324 [('adb -s 0123456789abcdef shell ls %s' %
1325 constants.DEVICE_LOCAL_PROPERTIES_PATH, 1325 constants.DEVICE_LOCAL_PROPERTIES_PATH,
1326 '%s\r\n' % constants.DEVICE_LOCAL_PROPERTIES_PATH), 1326 '%s\r\n' % constants.DEVICE_LOCAL_PROPERTIES_PATH),
1327 ('adb -s 0123456789abcdef pull %s %s' % 1327 ('adb -s 0123456789abcdef pull %s %s' %
1328 (constants.DEVICE_LOCAL_PROPERTIES_PATH, mock_file.name), 1328 (constants.DEVICE_LOCAL_PROPERTIES_PATH, mock_file.name),
1329 '100 B/s (100 bytes in 1.000s)\r\n'), 1329 '100 B/s (100 bytes in 1.000s)\r\n'),
1330 ('adb -s 0123456789abcdef push %s %s' % 1330 ('adb -s 0123456789abcdef push %s %s' %
1331 (mock_file.name, constants.DEVICE_LOCAL_PROPERTIES_PATH), 1331 (mock_file.name, constants.DEVICE_LOCAL_PROPERTIES_PATH),
1332 '100 B/s (100 bytes in 1.000s)\r\n'), 1332 '100 B/s (100 bytes in 1.000s)\r\n'),
1333 ('adb -s 0123456789abcdef shell ' 1333 ('adb -s 0123456789abcdef shell '
1334 'getprop dalvik.vm.enableassertions', 1334 'getprop dalvik.vm.enableassertions',
1335 'all\r\n'), 1335 'all\r\n'),
1336 ('adb -s 0123456789abcdef shell ' 1336 ('adb -s 0123456789abcdef shell '
1337 'setprop dalvik.vm.enableassertions ""', 1337 'setprop dalvik.vm.enableassertions ""',
1338 '')]): 1338 '')]):
1339 self.device.SetJavaAsserts(False) 1339 self.assertTrue(self.device.SetJavaAsserts(False))
1340 1340
1341 def testSetJavaAsserts_alreadyEnabled(self): 1341 def testSetJavaAsserts_alreadyEnabled(self):
1342 mock_file = self.mockNamedTemporary( 1342 mock_file = self.mockNamedTemporary(
1343 read_contents='dalvik.vm.enableassertions=all\n') 1343 read_contents='dalvik.vm.enableassertions=all\n')
1344 with mock.patch('tempfile.NamedTemporaryFile', 1344 with mock.patch('tempfile.NamedTemporaryFile',
1345 return_value=mock_file), ( 1345 return_value=mock_file), (
1346 mock.patch('__builtin__.open', return_value=mock_file)): 1346 mock.patch('__builtin__.open', return_value=mock_file)):
1347 with self.assertCallsSequence( 1347 with self.assertCallsSequence(
1348 [('adb -s 0123456789abcdef shell ls %s' % 1348 [('adb -s 0123456789abcdef shell ls %s' %
1349 constants.DEVICE_LOCAL_PROPERTIES_PATH, 1349 constants.DEVICE_LOCAL_PROPERTIES_PATH,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 self.device = device_utils.DeviceUtils(None) 1520 self.device = device_utils.DeviceUtils(None)
1521 with self.assertCalls('adb get-serialno', 'unknown'), ( 1521 with self.assertCalls('adb get-serialno', 'unknown'), (
1522 self.assertRaises(device_errors.NoDevicesError)): 1522 self.assertRaises(device_errors.NoDevicesError)):
1523 str(self.device) 1523 str(self.device)
1524 1524
1525 1525
1526 if __name__ == '__main__': 1526 if __name__ == '__main__':
1527 logging.getLogger().setLevel(logging.DEBUG) 1527 logging.getLogger().setLevel(logging.DEBUG)
1528 unittest.main(verbosity=2) 1528 unittest.main(verbosity=2)
1529 1529
OLDNEW
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698