at 24.11-pre 3.2 kB view raw
1import ./make-test-python.nix ({ pkgs, lib, ...} : { 2 name = "gnome"; 3 meta.maintainers = lib.teams.gnome.members; 4 5 nodes.machine = 6 { ... }: 7 8 { imports = [ ./common/user-account.nix ]; 9 10 services.xserver.enable = true; 11 12 services.xserver.displayManager = { 13 gdm.enable = true; 14 gdm.debug = true; 15 }; 16 17 services.displayManager.autoLogin = { 18 enable = true; 19 user = "alice"; 20 }; 21 22 services.xserver.desktopManager.gnome.enable = true; 23 services.xserver.desktopManager.gnome.debug = true; 24 25 systemd.user.services = { 26 "org.gnome.Shell@wayland" = { 27 serviceConfig = { 28 ExecStart = [ 29 # Clear the list before overriding it. 30 "" 31 # Eval API is now internal so Shell needs to run in unsafe mode. 32 # TODO: improve test driver so that it supports openqa-like manipulation 33 # that would allow us to drop this mess. 34 "${pkgs.gnome.gnome-shell}/bin/gnome-shell --unsafe-mode" 35 ]; 36 }; 37 }; 38 }; 39 40 }; 41 42 testScript = { nodes, ... }: let 43 # Keep line widths somewhat manageable 44 user = nodes.machine.users.users.alice; 45 uid = toString user.uid; 46 bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus"; 47 # Run a command in the appropriate user environment 48 run = command: "su - ${user.name} -c '${bus} ${command}'"; 49 50 # Call javascript in gnome shell, returns a tuple (success, output), where 51 # `success` is true if the dbus call was successful and output is what the 52 # javascript evaluates to. 53 eval = command: run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}"; 54 55 # False when startup is done 56 startingUp = eval "Main.layoutManager._startingUp"; 57 58 # Start Console 59 launchConsole = run "gapplication launch org.gnome.Console"; 60 61 # Hopefully Console's wm class 62 wmClass = eval "global.display.focus_window.wm_class"; 63 in '' 64 with subtest("Login to GNOME with GDM"): 65 # wait for gdm to start 66 machine.wait_for_unit("display-manager.service") 67 # wait for the wayland server 68 machine.wait_for_file("/run/user/${uid}/wayland-0") 69 # wait for alice to be logged in 70 machine.wait_for_unit("default.target", "${user.name}") 71 # check that logging in has given the user ownership of devices 72 assert "alice" in machine.succeed("getfacl -p /dev/snd/timer") 73 74 with subtest("Wait for GNOME Shell"): 75 # correct output should be (true, 'false') 76 machine.wait_until_succeeds( 77 "${startingUp} | grep -q 'true,..false'" 78 ) 79 80 with subtest("Open Console"): 81 # Close the Activities view so that Shell can correctly track the focused window. 82 machine.send_key("esc") 83 84 machine.succeed( 85 "${launchConsole}" 86 ) 87 # correct output should be (true, '"org.gnome.Console"') 88 machine.wait_until_succeeds( 89 "${wmClass} | grep -q 'true,...org.gnome.Console'" 90 ) 91 machine.sleep(20) 92 machine.screenshot("screen") 93 ''; 94})