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