1 import ./make-test-python.nix ({ pkgs, lib, ...} : {
4 maintainers = lib.teams.gnome.members;
7 nodes.machine = { nodes, ... }: let
8 user = nodes.machine.users.users.alice;
11 { imports = [ ./common/user-account.nix ];
13 services.xserver.enable = true;
15 services.xserver.displayManager = {
20 services.displayManager.autoLogin = {
25 services.xserver.desktopManager.gnome.enable = true;
26 services.xserver.desktopManager.gnome.debug = true;
27 services.displayManager.defaultSession = "gnome-xorg";
29 systemd.user.services = {
30 "org.gnome.Shell@x11" = {
33 # Clear the list before overriding it.
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-shell}/bin/gnome-shell --unsafe-mode"
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}'";
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}";
61 # False when startup is done
62 startingUp = eval "Main.layoutManager._startingUp";
65 launchConsole = run "gapplication launch org.gnome.Console";
67 # Hopefully Console's wm class
68 wmClass = eval "global.display.focus_window.wm_class";
70 with subtest("Login to GNOME Xorg with GDM"):
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")
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'"
85 with subtest("Open Console"):
86 # Close the Activities view so that Shell can correctly track the focused window.
87 machine.send_key("esc")
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'"
98 machine.screenshot("screen")