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

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

Issue 294113003: [Android] Convert to DeviceUtils versions of WaitUntilFullyBooted and GetExternalStoragePath. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 4c00e4941a8275a29afb78de6d1cfa17e58e4253..1ee7a06edba45b3b86ea25af3fd5461799629567 100644
--- a/build/android/pylib/device/device_utils_test.py
+++ b/build/android/pylib/device/device_utils_test.py
@@ -10,6 +10,7 @@ Unit tests for the contents of device_utils.py (mostly DeviceUtils).
# pylint: disable=W0613
import random
+import time
import unittest
from pylib import android_commands
@@ -70,9 +71,13 @@ class DeviceUtilsTest(unittest.TestCase):
@staticmethod
def _getTestAdbWrapper():
devices = adb_wrapper.AdbWrapper.GetDevices()
- if devices:
- return random.choice(devices)
- return None
+ start_time = time.time()
+ while time.time() - start_time < device_utils._DEFAULT_TIMEOUT:
+ if devices:
+ return random.choice(devices)
+ time.sleep(1)
+ raise device_errors.DeviceUnreachableError(
+ 'No devices available for testing...')
@staticmethod
def _getUnusedSerial():
@@ -143,6 +148,30 @@ class DeviceUtilsTest(unittest.TestCase):
d.EnableRoot()
self.assertTrue(d.HasRoot())
+ def testGetExternalStorage(self):
+ a = self._getTestAdbWrapper()
+ d = device_utils.DeviceUtils(a)
+
+ actual_external_storage = a.Shell('echo $EXTERNAL_STORAGE').splitlines()[0]
+ if actual_external_storage and len(actual_external_storage) != 0:
+ self.assertEquals(actual_external_storage, d.GetExternalStoragePath())
+
+ def testWaitUntilFullyBooted(self):
+ a = self._getTestAdbWrapper()
+ d = device_utils.DeviceUtils(a)
+
+ a.Reboot()
+ while a.GetState() == 'device':
+ time.sleep(0.1)
+ d.WaitUntilFullyBooted(wifi=True)
+ 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'))
+ self.assertTrue(
+ 'Wi-Fi is enabled' in a.Shell('dumpsys wifi').splitlines())
+
if __name__ == '__main__':
unittest.main(verbosity=2, buffer=True)
« 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