1import ./make-test-python.nix ({ pkgs, ...} : {
2 name = "xfce";
3
4 nodes.machine =
5 { pkgs, ... }:
6
7 {
8 imports = [
9 ./common/user-account.nix
10 ];
11
12 services.xserver.enable = true;
13
14 services.xserver.displayManager = {
15 lightdm.enable = true;
16 autoLogin = {
17 enable = true;
18 user = "alice";
19 };
20 };
21
22 services.xserver.desktopManager.xfce.enable = true;
23 environment.systemPackages = [ pkgs.xfce.xfce4-whiskermenu-plugin ];
24
25 hardware.pulseaudio.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
26
27 };
28
29 enableOCR = true;
30
31 testScript = { nodes, ... }: let
32 user = nodes.machine.users.users.alice;
33 bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus";
34 in ''
35 with subtest("Wait for login"):
36 machine.wait_for_x()
37 machine.wait_for_file("${user.home}/.Xauthority")
38 machine.succeed("xauth merge ${user.home}/.Xauthority")
39
40 with subtest("Check that logging in has given the user ownership of devices"):
41 machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
42
43 with subtest("Check if Xfce components actually start"):
44 machine.wait_for_window("xfce4-panel")
45 machine.wait_for_window("Desktop")
46 for i in ["xfwm4", "xfsettingsd", "xfdesktop", "xfce4-screensaver", "xfce4-notifyd", "xfconfd"]:
47 machine.wait_until_succeeds(f"pgrep -f {i}")
48
49 with subtest("Open whiskermenu"):
50 machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1 -t string -s whiskermenu -n >&2 &'")
51 machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfconf-query -c xfce4-panel -p /plugins/plugin-1/stay-on-focus-out -t bool -s true -n >&2 &'")
52 machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-panel -r >&2 &'")
53 machine.wait_until_succeeds("journalctl -b --grep 'xfce4-panel: Restarting' -t xsession")
54 machine.sleep(5)
55 machine.wait_until_succeeds("pgrep -f libwhiskermenu")
56 machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'")
57 machine.wait_for_text('Mail Reader')
58 # Close the menu.
59 machine.succeed("su - ${user.name} -c 'DISPLAY=:0 ${bus} xfce4-popup-whiskermenu >&2 &'")
60
61 with subtest("Open Xfce terminal"):
62 machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xfce4-terminal >&2 &'")
63 machine.wait_for_window("Terminal")
64
65 with subtest("Open Thunar"):
66 machine.succeed("su - ${user.name} -c 'DISPLAY=:0 thunar >&2 &'")
67 machine.wait_for_window("Thunar")
68 machine.wait_for_text('(Pictures|Public|Templates|Videos)')
69
70 with subtest("Check if any coredumps are found"):
71 machine.succeed("(coredumpctl --json=short 2>&1 || true) | grep 'No coredumps found'")
72 machine.sleep(10)
73 machine.screenshot("screen")
74 '';
75})