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 = {
24 services.xserver.desktopManager.gnome.enable = true;
25 services.xserver.desktopManager.gnome.debug = true;
26 services.xserver.displayManager.defaultSession = "gnome-xorg";
28 systemd.user.services = {
29 "org.gnome.Shell@x11" = {
32 # Clear the list before overriding it.
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"
45 testScript = { nodes, ... }: let
46 user = nodes.machine.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 # Run a command in the appropriate user environment
53 run = command: "su - ${user.name} -c '${bus} ${command}'";
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 = command: run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
60 # False when startup is done
61 startingUp = eval "Main.layoutManager._startingUp";
64 launchConsole = run "gapplication launch org.gnome.Console";
66 # Hopefully Console's wm class
67 wmClass = eval "global.display.focus_window.wm_class";
69 with subtest("Login to GNOME Xorg with GDM"):
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")
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'"
84 with subtest("Open Console"):
85 # Close the Activities view so that Shell can correctly track the focused window.
86 machine.send_key("esc")
91 # correct output should be (true, '"kgx"')
92 # For some reason, this deviates from Wayland.
93 machine.wait_until_succeeds(
94 "${wmClass} | grep -q 'true,...kgx'"
97 machine.screenshot("screen")