mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-27 11:36:29 +03:00
nixos/tests/chromium: Refactor launching the browser process
It should now be more flexible and less error-prone.
This commit is contained in:
parent
faec8bbbf7
commit
8c52061b1f
1 changed files with 13 additions and 13 deletions
|
@ -63,8 +63,8 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
||||||
return "su - ${user} -c " + shlex.quote(cmd)
|
return "su - ${user} -c " + shlex.quote(cmd)
|
||||||
|
|
||||||
|
|
||||||
def get_browser_call():
|
def launch_browser():
|
||||||
"""Returns the name of the browser binary as well as CLI options."""
|
"""Launches the web browser with the correct options."""
|
||||||
# Determine the name of the binary:
|
# Determine the name of the binary:
|
||||||
pname = "${getName chromiumPkg.name}"
|
pname = "${getName chromiumPkg.name}"
|
||||||
if pname.find("chromium") != -1:
|
if pname.find("chromium") != -1:
|
||||||
|
@ -76,12 +76,19 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
||||||
else: # For google-chrome-beta and as fallback:
|
else: # For google-chrome-beta and as fallback:
|
||||||
binary = pname
|
binary = pname
|
||||||
# Add optional CLI options:
|
# Add optional CLI options:
|
||||||
options = ""
|
options = []
|
||||||
major_version = "${versions.major (getVersion chromiumPkg.name)}"
|
major_version = "${versions.major (getVersion chromiumPkg.name)}"
|
||||||
if major_version > "91":
|
if major_version > "91":
|
||||||
# To avoid a GPU crash:
|
# To avoid a GPU crash:
|
||||||
options += "--use-gl=angle --use-angle=swiftshader"
|
options += ["--use-gl=angle", "--use-angle=swiftshader"]
|
||||||
return f"{binary} {options}"
|
options.append("file://${startupHTML}")
|
||||||
|
# Launch the process:
|
||||||
|
machine.succeed(ru(f'ulimit -c unlimited; {binary} {shlex.join(options)} & disown'))
|
||||||
|
if binary.startswith("google-chrome"):
|
||||||
|
# Need to click away the first window:
|
||||||
|
machine.wait_for_text("Make Google Chrome the default browser")
|
||||||
|
machine.screenshot("google_chrome_default_browser_prompt")
|
||||||
|
machine.send_key("ret")
|
||||||
|
|
||||||
|
|
||||||
def create_new_win():
|
def create_new_win():
|
||||||
|
@ -142,14 +149,7 @@ mapAttrs (channel: chromiumPkg: makeTest rec {
|
||||||
|
|
||||||
machine.wait_for_x()
|
machine.wait_for_x()
|
||||||
|
|
||||||
url = "file://${startupHTML}"
|
launch_browser()
|
||||||
machine.succeed(ru(f'ulimit -c unlimited; {get_browser_call()} "{url}" & disown'))
|
|
||||||
|
|
||||||
if get_browser_call().startswith("google-chrome"):
|
|
||||||
# Need to click away the first window:
|
|
||||||
machine.wait_for_text("Make Google Chrome the default browser")
|
|
||||||
machine.screenshot("google_chrome_default_browser_prompt")
|
|
||||||
machine.send_key("ret")
|
|
||||||
|
|
||||||
machine.wait_for_text("startup done")
|
machine.wait_for_text("startup done")
|
||||||
machine.wait_until_succeeds(
|
machine.wait_until_succeeds(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue