mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
run_in_headless_android_emulator: add some code comments
This commit is contained in:
parent
94d1acbcfd
commit
e6eca2bce4
1 changed files with 21 additions and 1 deletions
|
@ -50,16 +50,28 @@ def main(avd_name, apk_path, *args):
|
||||||
# that might still be in the midle of starting and not be responsive yet.
|
# that might still be in the midle of starting and not be responsive yet.
|
||||||
wait_for_boot(adb)
|
wait_for_boot(adb)
|
||||||
|
|
||||||
|
# These steps should happen before application start
|
||||||
check_call(adb + ["install", "-r", apk_path])
|
check_call(adb + ["install", "-r", apk_path])
|
||||||
args = list(args)
|
args = list(args)
|
||||||
write_user_stylesheets(adb, args)
|
write_user_stylesheets(adb, args)
|
||||||
write_args(adb, args)
|
write_args(adb, args)
|
||||||
|
|
||||||
check_call(adb + ["shell", "am start com.mozilla.servo/com.mozilla.servo.MainActivity"],
|
check_call(adb + ["shell", "am start com.mozilla.servo/com.mozilla.servo.MainActivity"],
|
||||||
stdout=sys.stderr)
|
stdout=sys.stderr)
|
||||||
|
|
||||||
logcat_args = ["RustAndroidGlueStdouterr:D", "*:S", "-v", "raw"]
|
# Start showing logs as soon as the application starts,
|
||||||
|
# in case they say something useful while we wait in subsequent steps.
|
||||||
|
logcat_args = [
|
||||||
|
"--format=raw", # Print no metadata, only log messages
|
||||||
|
"RustAndroidGlueStdouterr:D", # Show (debug level) Rust stdio
|
||||||
|
"*:S", # Hide everything else
|
||||||
|
]
|
||||||
with terminate_on_exit(adb + ["logcat"] + logcat_args) as logcat:
|
with terminate_on_exit(adb + ["logcat"] + logcat_args) as logcat:
|
||||||
|
|
||||||
|
# This step needs to happen after application start
|
||||||
forward_webdriver(adb, args)
|
forward_webdriver(adb, args)
|
||||||
|
|
||||||
|
# logcat normally won't exit on its own, wait until we get a SIGTERM signal.
|
||||||
logcat.wait()
|
logcat.wait()
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,7 +146,15 @@ def write_user_stylesheets(adb, args):
|
||||||
def forward_webdriver(adb, args):
|
def forward_webdriver(adb, args):
|
||||||
webdriver_port = extract_arg("--webdriver", args)
|
webdriver_port = extract_arg("--webdriver", args)
|
||||||
if webdriver_port is not None:
|
if webdriver_port is not None:
|
||||||
|
# `adb forward` will start accepting TCP connections even if the other side does not.
|
||||||
|
# (If the remote side refuses the connection,
|
||||||
|
# adb will close the local side after accepting it.)
|
||||||
|
# This is incompatible with wptrunner which relies on TCP connection acceptance
|
||||||
|
# to figure out when it can start sending WebDriver requests.
|
||||||
|
#
|
||||||
|
# So wait until the remote side starts listening before setting up the forwarding.
|
||||||
wait_for_tcp_server(adb, webdriver_port)
|
wait_for_tcp_server(adb, webdriver_port)
|
||||||
|
|
||||||
port = "tcp:%s" % webdriver_port
|
port = "tcp:%s" % webdriver_port
|
||||||
check_call(adb + ["forward", port, port])
|
check_call(adb + ["forward", port, port])
|
||||||
sys.stderr.write("Forwarding WebDriver port %s to the emulator\n" % webdriver_port)
|
sys.stderr.write("Forwarding WebDriver port %s to the emulator\n" % webdriver_port)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue