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