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 virtualisation.memorySize = 1024;
29 };
30
31 testScript = { nodes, ... }: let
32 user = nodes.machine.config.users.users.alice;
33 uid = toString user.uid;
34 bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
35 xauthority = "/run/user/${uid}/gdm/Xauthority";
36 display = "DISPLAY=:0.0";
37 env = "${bus} XAUTHORITY=${xauthority} ${display}";
38 gdbus = "${env} gdbus";
39 su = command: "su - ${user.name} -c '${env} ${command}'";
40
41 # Call javascript in gnome shell, returns a tuple (success, output), where
42 # `success` is true if the dbus call was successful and output is what the
43 # javascript evaluates to.
44 eval = "call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval";
45
46 # False when startup is done
47 startingUp = su "${gdbus} ${eval} Main.layoutManager._startingUp";
48
49 # Start gnome-terminal
50 gnomeTerminalCommand = su "gnome-terminal";
51
52 # Hopefully gnome-terminal's wm class
53 wmClass = su "${gdbus} ${eval} global.display.focus_window.wm_class";
54 in ''
55 with subtest("Login to GNOME Xorg with GDM"):
56 machine.wait_for_x()
57 # Wait for alice to be logged in"
58 machine.wait_for_unit("default.target", "${user.name}")
59 machine.wait_for_file("${xauthority}")
60 machine.succeed("xauth merge ${xauthority}")
61 # Check that logging in has given the user ownership of devices
62 assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
63
64 with subtest("Wait for GNOME Shell"):
65 # correct output should be (true, 'false')
66 machine.wait_until_succeeds(
67 "${startingUp} | grep -q 'true,..false'"
68 )
69
70 with subtest("Open Gnome Terminal"):
71 machine.succeed(
72 "${gnomeTerminalCommand}"
73 )
74 # correct output should be (true, '"Gnome-terminal"')
75 machine.wait_until_succeeds(
76 "${wmClass} | grep -q 'true,...Gnome-terminal'"
77 )
78 machine.sleep(20)
79 machine.screenshot("screen")
80 '';
81})