Release NixOS 23.11
[NixPkgs.git] / nixos / tests / gnome.nix
blob91182790cb24862fd13bec9fc0dc5929f8c6e6be
1 import ./make-test-python.nix ({ pkgs, lib, ...} : {
2   name = "gnome";
3   meta.maintainers = lib.teams.gnome.members;
5   nodes.machine =
6     { ... }:
8     { imports = [ ./common/user-account.nix ];
10       services.xserver.enable = true;
12       services.xserver.displayManager = {
13         gdm.enable = true;
14         gdm.debug = true;
15         autoLogin = {
16           enable = true;
17           user = "alice";
18         };
19       };
21       services.xserver.desktopManager.gnome.enable = true;
22       services.xserver.desktopManager.gnome.debug = true;
24       systemd.user.services = {
25         "org.gnome.Shell@wayland" = {
26           serviceConfig = {
27             ExecStart = [
28               # Clear the list before overriding it.
29               ""
30               # Eval API is now internal so Shell needs to run in unsafe mode.
31               # TODO: improve test driver so that it supports openqa-like manipulation
32               # that would allow us to drop this mess.
33               "${pkgs.gnome.gnome-shell}/bin/gnome-shell --unsafe-mode"
34             ];
35           };
36         };
37       };
39     };
41   testScript = { nodes, ... }: let
42     # Keep line widths somewhat manageable
43     user = nodes.machine.users.users.alice;
44     uid = toString user.uid;
45     bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus";
46     # Run a command in the appropriate user environment
47     run = command: "su - ${user.name} -c '${bus} ${command}'";
49     # Call javascript in gnome shell, returns a tuple (success, output), where
50     # `success` is true if the dbus call was successful and output is what the
51     # javascript evaluates to.
52     eval = command: run "gdbus call --session -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval ${command}";
54     # False when startup is done
55     startingUp = eval "Main.layoutManager._startingUp";
57     # Start Console
58     launchConsole = run "gapplication launch org.gnome.Console";
60     # Hopefully Console's wm class
61     wmClass = eval "global.display.focus_window.wm_class";
62   in ''
63       with subtest("Login to GNOME with GDM"):
64           # wait for gdm to start
65           machine.wait_for_unit("display-manager.service")
66           # wait for the wayland server
67           machine.wait_for_file("/run/user/${uid}/wayland-0")
68           # wait for alice to be logged in
69           machine.wait_for_unit("default.target", "${user.name}")
70           # check that logging in has given the user ownership of devices
71           assert "alice" in machine.succeed("getfacl -p /dev/snd/timer")
73       with subtest("Wait for GNOME Shell"):
74           # correct output should be (true, 'false')
75           machine.wait_until_succeeds(
76               "${startingUp} | grep -q 'true,..false'"
77           )
79       with subtest("Open Console"):
80           # Close the Activities view so that Shell can correctly track the focused window.
81           machine.send_key("esc")
83           machine.succeed(
84               "${launchConsole}"
85           )
86           # correct output should be (true, '"org.gnome.Console"')
87           machine.wait_until_succeeds(
88               "${wmClass} | grep -q 'true,...org.gnome.Console'"
89           )
90           machine.sleep(20)
91           machine.screenshot("screen")
92     '';