summaryrefslogtreecommitdiffstats
path: root/third_party/android_testrunner
diff options
context:
space:
mode:
authorjames.wei@intel.com <james.wei@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 03:30:04 +0000
committerjames.wei@intel.com <james.wei@intel.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-11 03:30:04 +0000
commita9bd5a3bfcf649dbf7ccb92a62a25850f4d46145 (patch)
tree908d975e5a35f2220b707c8e02704166a4ac6001 /third_party/android_testrunner
parentc44e5c806fcd975c383c32ee46aa3f8156ca3dd3 (diff)
downloadchromium_src-a9bd5a3bfcf649dbf7ccb92a62a25850f4d46145.zip
chromium_src-a9bd5a3bfcf649dbf7ccb92a62a25850f4d46145.tar.gz
chromium_src-a9bd5a3bfcf649dbf7ccb92a62a25850f4d46145.tar.bz2
fix test broken issue when using --use-emulator
BUG=136474 TEST=./build/android/run_tests.py -s out/Release/base_unittests_apk/base_unittests-debug.apk -e 1 Review URL: https://chromiumcodereview.appspot.com/10692132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146045 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/android_testrunner')
-rw-r--r--third_party/android_testrunner/README.chromium5
-rw-r--r--third_party/android_testrunner/adb_interface.py48
2 files changed, 51 insertions, 2 deletions
diff --git a/third_party/android_testrunner/README.chromium b/third_party/android_testrunner/README.chromium
index c8a97fa..a2e76f0 100644
--- a/third_party/android_testrunner/README.chromium
+++ b/third_party/android_testrunner/README.chromium
@@ -9,8 +9,9 @@ This package is the scripts used to run the unit test for Android and from
Android Gingerbread.
Local Modifications:
-This are no local modifications, all files were copied from
-<android_gingerbread_tree>/development/testrunner/
+1. Added functions to start/kill/restart the adb server.
+2. Added function of WaitForSystemBootCompleted to wait for the flag of
+sys.boot_completed to be set.
Here is the detail steps
1. Checkout Android source code
diff --git a/third_party/android_testrunner/adb_interface.py b/third_party/android_testrunner/adb_interface.py
index 1928c73..9109916 100644
--- a/third_party/android_testrunner/adb_interface.py
+++ b/third_party/android_testrunner/adb_interface.py
@@ -51,6 +51,21 @@ class AdbInterface:
"""Direct all future commands to Android target with the given serial."""
self._target_arg = "-s %s" % serial
+ def RestartAdbServer(self):
+ """Restart the adb server."""
+ self.KillAdbServer()
+ self.StartAdbServer()
+
+ def KillAdbServer(self):
+ """Kill adb server."""
+ adb_cmd = "adb kill-server"
+ return run_command.RunCommand(adb_cmd)
+
+ def StartAdbServer(self):
+ """Start adb server."""
+ adb_cmd = "adb start-server"
+ return run_command.RunCommand(adb_cmd)
+
def SendCommand(self, command_string, timeout_time=20, retry_count=3):
"""Send a command via adb.
@@ -419,6 +434,39 @@ class AdbInterface:
if not success:
raise errors.WaitForResponseTimedOutError()
+ def WaitForSystemBootCompleted(self, wait_time=120):
+ """Waits for targeted system's boot_completed flag to be set.
+
+ Args:
+ wait_time: time in seconds to wait
+
+ Raises:
+ WaitForResponseTimedOutError if wait_time elapses and flag still not
+ set.
+ """
+ logger.Log("Waiting for system boot completed...")
+ self.SendCommand("wait-for-device")
+ # Now the device is there, but system not boot completed.
+ # Query the sys.boot_completed flag with a basic command
+ boot_completed = False
+ attempts = 0
+ wait_period = 5
+ while not boot_completed and (attempts*wait_period) < wait_time:
+ output = self.SendShellCommand("getprop sys.boot_completed", retry_count=1)
+ output = output.strip()
+ if output == "1":
+ boot_completed = True
+ else:
+ # If 'error: xxx' returned when querying the flag, it means
+ # adb server lost the connection to the emulator, so restart the adb server.
+ if "error:" in output:
+ self.RestartAdbServer()
+ time.sleep(wait_period)
+ attempts += 1
+ if not boot_completed:
+ raise errors.WaitForResponseTimedOutError(
+ "sys.boot_completed flag was not set after %s seconds" % wait_time)
+
def WaitForBootComplete(self, wait_time=120):
"""Waits for targeted device's bootcomplete flag to be set.