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

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

Issue 1167903006: [Android] Speculative fix for DeviceUtils.EnableRoot issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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') | no next file » | 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 23a1a325e7680dda7e12d2fa8a3c8e6a084b8d3b..317e81e83b619ea83afa8b93c9cab6767a8c1159 100755
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -140,6 +140,18 @@ class DeviceUtilsTest(mock_calls.TestCase):
self.adb, default_timeout=10, default_retries=0)
self.watchMethodCalls(self.call.adb, ignore=['GetDeviceSerial'])
+ def AdbCommandError(self, args=None, output=None, status=None, msg=None):
+ if args is None:
+ args = ['[unspecified]']
+ return mock.Mock(side_effect=device_errors.AdbCommandFailedError(
+ args, output, status, msg, str(self.device)))
+
+ def CommandError(self, msg=None):
+ if msg is None:
+ msg = 'Command failed'
+ return mock.Mock(side_effect=device_errors.CommandFailedError(
+ msg, str(self.device)))
+
def ShellError(self, output=None, status=1):
def action(cmd, *args, **kwargs):
raise device_errors.AdbShellCommandFailedError(
@@ -154,12 +166,6 @@ class DeviceUtilsTest(mock_calls.TestCase):
return mock.Mock(side_effect=device_errors.CommandTimeoutError(
msg, str(self.device)))
- def CommandError(self, msg=None):
- if msg is None:
- msg = 'Command failed'
- return mock.Mock(side_effect=device_errors.CommandFailedError(
- msg, str(self.device)))
-
class DeviceUtilsEqTest(DeviceUtilsTest):
@@ -259,8 +265,8 @@ class DeviceUtilsEnableRootTest(DeviceUtilsTest):
def testEnableRoot_succeeds(self):
with self.assertCalls(
(self.call.device.IsUserBuild(), False),
- self.call.adb.Root(),
- self.call.adb.WaitForDevice()):
+ self.call.adb.Root(),
+ self.call.device.WaitUntilFullyBooted()):
self.device.EnableRoot()
def testEnableRoot_userBuild(self):
@@ -362,6 +368,27 @@ class DeviceUtilsWaitUntilFullyBootedTest(DeviceUtilsTest):
'stuff\nWi-Fi is enabled\nmore stuff\n')):
self.device.WaitUntilFullyBooted(wifi=True)
+ def testWaitUntilFullyBooted_deviceNotInitiallyAvailable(self):
+ with self.assertCalls(
+ self.call.adb.WaitForDevice(),
+ # sd_card_ready
+ (self.call.device.GetExternalStoragePath(), self.AdbCommandError()),
+ # sd_card_ready
+ (self.call.device.GetExternalStoragePath(), self.AdbCommandError()),
+ # sd_card_ready
+ (self.call.device.GetExternalStoragePath(), self.AdbCommandError()),
+ # sd_card_ready
+ (self.call.device.GetExternalStoragePath(), self.AdbCommandError()),
+ # sd_card_ready
+ (self.call.device.GetExternalStoragePath(), '/fake/storage/path'),
+ (self.call.adb.Shell('test -d /fake/storage/path'), ''),
+ # pm_ready
+ (self.call.device.GetApplicationPath('android'),
+ 'package:/some/fake/path'),
+ # boot_completed
+ (self.call.device.GetProp('sys.boot_completed'), '1')):
+ self.device.WaitUntilFullyBooted(wifi=False)
+
def testWaitUntilFullyBooted_sdCardReadyFails_noPath(self):
with self.assertCalls(
self.call.adb.WaitForDevice(),
« 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