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

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

Issue 292313015: [Android] Switch to DeviceUtils versions of Reboot and Install. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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') | build/android/pylib/gtest/test_package_apk.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 1ee7a06edba45b3b86ea25af3fd5461799629567..4c4369fc6ade20dbab79d56e778046bfa186822d 100644
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -9,6 +9,7 @@ Unit tests for the contents of device_utils.py (mostly DeviceUtils).
# pylint: disable=W0212
# pylint: disable=W0613
+import functools
import random
import time
import unittest
@@ -20,10 +21,20 @@ from pylib.device import device_errors
from pylib.device import device_utils
+def TestRequiresDevice(f):
+ @functools.wraps(f)
+ def wrapper(*args, **kwargs):
+ if len(adb_wrapper.AdbWrapper.GetDevices()) > 0:
+ return f(*args, **kwargs)
+ return unittest.skip('Test requires an attached device.')
+ return wrapper
+
+
class DeviceUtilsTest(unittest.TestCase):
def testGetAVDs(self):
pass
+ @TestRequiresDevice
def testRestartServerNotRunning(self):
self.assertEqual(0, cmd_helper.RunCmd(['pkill', 'adb']),
msg='Unable to kill adb during setup.')
@@ -32,6 +43,7 @@ class DeviceUtilsTest(unittest.TestCase):
device_utils.RestartServer()
self.assertEqual(0, cmd_helper.RunCmd(['pgrep', 'adb']))
+ @TestRequiresDevice
def testRestartServerAlreadyRunning(self):
if cmd_helper.RunCmd(['pgrep', 'adb']) != 0:
device_utils.RestartServer()
@@ -89,12 +101,14 @@ class DeviceUtilsTest(unittest.TestCase):
if serial not in used_devices:
return serial
+ @TestRequiresDevice
def testIsOnline(self):
d = device_utils.DeviceUtils(self._getTestAdbWrapper())
self.assertTrue(d is None or d.IsOnline())
d = device_utils.DeviceUtils(self._getUnusedSerial())
self.assertFalse(d.IsOnline())
+ @TestRequiresDevice
def testHasRoot(self):
a = self._getTestAdbWrapper()
d = device_utils.DeviceUtils(a)
@@ -112,6 +126,7 @@ class DeviceUtilsTest(unittest.TestCase):
else:
self.assertTrue(d.HasRoot())
+ @TestRequiresDevice
def testEnableRoot(self):
a = self._getTestAdbWrapper()
d = device_utils.DeviceUtils(a)
@@ -148,6 +163,7 @@ class DeviceUtilsTest(unittest.TestCase):
d.EnableRoot()
self.assertTrue(d.HasRoot())
+ @TestRequiresDevice
def testGetExternalStorage(self):
a = self._getTestAdbWrapper()
d = device_utils.DeviceUtils(a)
@@ -156,6 +172,7 @@ class DeviceUtilsTest(unittest.TestCase):
if actual_external_storage and len(actual_external_storage) != 0:
self.assertEquals(actual_external_storage, d.GetExternalStoragePath())
+ @TestRequiresDevice
def testWaitUntilFullyBooted(self):
a = self._getTestAdbWrapper()
d = device_utils.DeviceUtils(a)
@@ -172,7 +189,25 @@ class DeviceUtilsTest(unittest.TestCase):
self.assertTrue(
'Wi-Fi is enabled' in a.Shell('dumpsys wifi').splitlines())
+ @TestRequiresDevice
+ def testBlockingReboot(self):
+ a = self._getTestAdbWrapper()
+ d = device_utils.DeviceUtils(a)
+
+ old_boot_time = a.Shell('getprop ro.runtime.firstboot').strip()
+ if old_boot_time and len(old_boot_time):
+ d.Reboot(block=True, timeout=120)
+ self.assertNotEquals(old_boot_time,
+ a.Shell('getprop ro.runtime.firstboot').strip())
+ self.assertEquals(
+ '1', a.Shell('getprop sys.boot_completed').splitlines()[0])
+ self.assertTrue(
+ a.Shell('pm path android').splitlines()[0].startswith('package:'))
+ self.assertTrue(a.Shell('ls $EXTERNAL_STORAGE'))
+ else:
+ self.skipTest("No 'ro.runtime.firstboot' property on %s." % str(a))
+
if __name__ == '__main__':
- unittest.main(verbosity=2, buffer=True)
+ unittest.main(verbosity=2)
« no previous file with comments | « build/android/pylib/device/device_utils.py ('k') | build/android/pylib/gtest/test_package_apk.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698