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.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 Console
64 launchConsole = su "${bus} gapplication launch org.gnome.Console";
65
66 # Hopefully Console'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 Console"):
85 # Close the Activities view so that Shell can correctly track the focused window.
86 machine.send_key("esc")
87
88 machine.succeed(
89 "${launchConsole}"
90 )
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'"
95 )
96 machine.sleep(20)
97 machine.screenshot("screen")
98 '';
99})