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

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

Issue 404993004: [Android] Switch to DeviceUtils versions of GetMemoryUsageForPid and __str__. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment from frankf Created 6 years, 5 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/forwarder.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 bd671d1a4e980a6d98a7c39466345a1279ecb183..b6a99d28d4bb7fb85a0a0b00c37283a1063d2d26 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -1443,6 +1443,48 @@ class DeviceUtilsGetIOStatsTest(DeviceUtilsOldImplTest):
self.device.GetIOStats())
+class DeviceUtilsGetMemoryUsageForPidTest(DeviceUtilsOldImplTest):
+
+ def setUp(self):
+ super(DeviceUtilsGetMemoryUsageForPidTest, self).setUp()
+ self.device.old_interface._privileged_command_runner = (
+ self.device.old_interface.RunShellCommand)
+ self.device.old_interface._protected_file_access_method_initialized = True
+
+ def testGetMemoryUsageForPid_validPid(self):
+ with self.assertCallsSequence([
+ ("adb -s 0123456789abcdef shell 'showmap 1234'",
+ '100 101 102 103 104 105 106 107 TOTAL\r\n'),
+ ("adb -s 0123456789abcdef shell "
+ "'cat \"/proc/1234/status\" 2> /dev/null'",
+ 'VmHWM: 1024 kB')
+ ]):
+ self.assertEqual(
+ {
+ 'Size': 100,
+ 'Rss': 101,
+ 'Pss': 102,
+ 'Shared_Clean': 103,
+ 'Shared_Dirty': 104,
+ 'Private_Clean': 105,
+ 'Private_Dirty': 106,
+ 'VmHWM': 1024
+ },
+ self.device.GetMemoryUsageForPid(1234))
+
+ def testGetMemoryUsageForPid_invalidPid(self):
+ with self.assertCalls(
+ "adb -s 0123456789abcdef shell 'showmap 4321'",
+ 'cannot open /proc/4321/smaps: No such file or directory\r\n'):
+ self.assertEqual({}, self.device.GetMemoryUsageForPid(4321))
+
+
+class DeviceUtilsStrTest(DeviceUtilsOldImplTest):
+ def testStr_noAdbCalls(self):
+ with self.assertNoAdbCalls():
+ self.assertEqual('0123456789abcdef', str(self.device))
+
+
if __name__ == '__main__':
logging.getLogger().setLevel(logging.DEBUG)
unittest.main(verbosity=2)
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | build/android/pylib/forwarder.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698