mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
run_in_headless_android_emulator: add support for user stylesheets
This commit is contained in:
parent
33234affc9
commit
d7495a2297
1 changed files with 19 additions and 3 deletions
|
@ -51,6 +51,8 @@ def main(avd_name, apk_path, *args):
|
||||||
wait_for_boot(adb)
|
wait_for_boot(adb)
|
||||||
|
|
||||||
check_call(adb + ["install", "-r", apk_path])
|
check_call(adb + ["install", "-r", apk_path])
|
||||||
|
args = list(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)
|
||||||
|
@ -120,6 +122,15 @@ def write_args(adb, args):
|
||||||
check_call(adb + ["shell", "echo %s >> %s" % (shell_quote(arg), params_file)])
|
check_call(adb + ["shell", "echo %s >> %s" % (shell_quote(arg), params_file)])
|
||||||
|
|
||||||
|
|
||||||
|
def write_user_stylesheets(adb, args):
|
||||||
|
data_dir = "/sdcard/Android/data/com.mozilla.servo/files"
|
||||||
|
check_call(adb + ["shell", "mkdir -p %s" % data_dir])
|
||||||
|
for i, (pos, path) in enumerate(extract_args("--user-stylesheet", args)):
|
||||||
|
remote_path = "%s/user%s.css" % (data_dir, i)
|
||||||
|
args[pos] = remote_path
|
||||||
|
check_call(adb + ["push", path, remote_path], stdout=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
|
@ -130,15 +141,20 @@ def forward_webdriver(adb, args):
|
||||||
|
|
||||||
|
|
||||||
def extract_arg(name, args):
|
def extract_arg(name, args):
|
||||||
|
for _, arg in extract_args(name, args):
|
||||||
|
return arg
|
||||||
|
|
||||||
|
|
||||||
|
def extract_args(name, args):
|
||||||
previous_arg_matches = False
|
previous_arg_matches = False
|
||||||
for arg in args:
|
for i, arg in enumerate(args):
|
||||||
if previous_arg_matches:
|
if previous_arg_matches:
|
||||||
return arg
|
yield i, arg
|
||||||
previous_arg_matches = arg == name
|
previous_arg_matches = arg == name
|
||||||
|
|
||||||
|
|
||||||
def wait_for_tcp_server(adb, port):
|
def wait_for_tcp_server(adb, port):
|
||||||
while call(adb + ["shell", "nc -z 127.0.0.1 %s" % port]) != 0:
|
while call(adb + ["shell", "nc -z 127.0.0.1 %s" % port], stdout=sys.stderr) != 0:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue