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

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

Issue 547623002: Simpler logic to setup/restore Chrome command line (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nit (lined up params) Created 6 years, 3 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
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 2692e1255b801a5961980f47956c8e8fb9616f63..59f3b5e52ccd0213a0ad4a014fad26b0af20d403 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -1207,6 +1207,44 @@ class DeviceUtilsWriteFileTest(DeviceUtilsOldImplTest):
self.device.WriteFile('/test/file/no.permissions.to.write',
'new test file contents', as_root=True)
+class DeviceUtilsWriteTextFileTest(DeviceUtilsOldImplTest):
+
+ def testWriteTextFileTest_basic(self):
+ with self.assertCalls(
+ "adb -s 0123456789abcdef shell 'echo some.string"
+ " > /test/file/to.write; echo %$?'", '%0\r\n'):
+ self.device.WriteTextFile('/test/file/to.write', 'some.string')
+
+ def testWriteTextFileTest_stringWithSpaces(self):
+ with self.assertCalls(
+ "adb -s 0123456789abcdef shell 'echo '\\''some other string'\\''"
+ " > /test/file/to.write; echo %$?'", '%0\r\n'):
+ self.device.WriteTextFile('/test/file/to.write', 'some other string')
+
+ def testWriteTextFileTest_asRoot_withSu(self):
+ with self.assertCallsSequence([
+ ("adb -s 0123456789abcdef shell 'ls /root'", 'Permission denied\r\n'),
+ ("adb -s 0123456789abcdef shell 'su -c echo some.string"
+ " > /test/file/to.write; echo %$?'", '%0\r\n')]):
+ self.device.WriteTextFile('/test/file/to.write', 'some.string',
+ as_root=True)
+
+ def testWriteTextFileTest_asRoot_withRoot(self):
+ with self.assertCallsSequence([
+ ("adb -s 0123456789abcdef shell 'ls /root'", 'hello\r\nworld\r\n'),
+ ("adb -s 0123456789abcdef shell 'echo some.string"
+ " > /test/file/to.write; echo %$?'", '%0\r\n')]):
+ self.device.WriteTextFile('/test/file/to.write', 'some.string',
+ as_root=True)
+
+ def testWriteTextFileTest_asRoot_rejected(self):
+ with self.assertCallsSequence([
+ ("adb -s 0123456789abcdef shell 'ls /root'", 'Permission denied\r\n'),
+ ("adb -s 0123456789abcdef shell 'su -c echo some.string"
+ " > /test/file/to.write; echo %$?'", '%1\r\n')]):
+ with self.assertRaises(device_errors.CommandFailedError):
+ self.device.WriteTextFile('/test/file/to.write', 'some.string',
+ as_root=True)
class DeviceUtilsLsTest(DeviceUtilsOldImplTest):
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | tools/telemetry/telemetry/core/backends/chrome/android_browser_backend.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698