Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some support for WPT tests in an Android emulator through WebDriver #21213

Merged
merged 15 commits into from Jul 21, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

run_in_headless_android_emulator: add port forwarding for webdriver

  • Loading branch information
SimonSapin committed Jul 19, 2018
commit 33234affc902d95b18d13a2306afa735e10e0e48
@@ -57,6 +57,7 @@ def main(avd_name, apk_path, *args):

logcat_args = ["RustAndroidGlueStdouterr:D", "*:S", "-v", "raw"]
with terminate_on_exit(adb + ["logcat"] + logcat_args) as logcat:
forward_webdriver(adb, args)
logcat.wait()


@@ -119,6 +120,28 @@ def write_args(adb, args):
check_call(adb + ["shell", "echo %s >> %s" % (shell_quote(arg), params_file)])


def forward_webdriver(adb, args):
webdriver_port = extract_arg("--webdriver", args)
if webdriver_port is not None:
wait_for_tcp_server(adb, webdriver_port)
port = "tcp:%s" % webdriver_port
check_call(adb + ["forward", port, port])
sys.stderr.write("Forwarding WebDriver port %s to the emulator\n" % webdriver_port)


def extract_arg(name, args):
previous_arg_matches = False
for arg in args:
if previous_arg_matches:
return arg
previous_arg_matches = arg == name


def wait_for_tcp_server(adb, port):
while call(adb + ["shell", "nc -z 127.0.0.1 %s" % port]) != 0:
time.sleep(1)


# Copied from Python 3.3+'s shlex.quote()
def shell_quote(arg):
# use single quotes, and put single quotes into double quotes
@@ -57,8 +57,8 @@ def __init__(self, executor, browser, capabilities, **kwargs):

def connect(self):
"""Connect to browser via WebDriver."""
# Largish timeout for the case where we're booting an Android emulator.
wait_for_service((self.host, self.port), timeout=120)
# Large timeout for the case where we're booting an Android emulator.
wait_for_service((self.host, self.port), timeout=300)

self.session = webdriver.Session(self.host, self.port, extension=ServoCommandExtensions)
self.session.start()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.