Skip to content

Commit 9e74210

Browse files
committed
nixosTests.pantheon-wayland: init
It is unclear to me how to properly start apps so I am using autostart here.
1 parent 1c26dec commit 9e74210

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

nixos/tests/all-tests.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ in {
802802
patroni = handleTestOn ["x86_64-linux"] ./patroni.nix {};
803803
pantalaimon = handleTest ./matrix/pantalaimon.nix {};
804804
pantheon = handleTest ./pantheon.nix {};
805+
pantheon-wayland = handleTest ./pantheon-wayland.nix {};
805806
paperless = handleTest ./paperless.nix {};
806807
parsedmarc = handleTest ./parsedmarc {};
807808
password-option-override-ordering = handleTest ./password-option-override-ordering.nix {};

nixos/tests/pantheon-wayland.nix

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import ./make-test-python.nix (
2+
{ pkgs, lib, ... }:
3+
4+
{
5+
name = "pantheon-wayland";
6+
7+
meta.maintainers = lib.teams.pantheon.members;
8+
9+
nodes.machine =
10+
{ nodes, ... }:
11+
12+
let
13+
videosAutostart = pkgs.writeTextFile {
14+
name = "autostart-elementary-videos";
15+
destination = "/etc/xdg/autostart/io.elementary.videos.desktop";
16+
text = ''
17+
[Desktop Entry]
18+
Version=1.0
19+
Name=Videos
20+
Type=Application
21+
Terminal=false
22+
Exec=io.elementary.videos %U
23+
'';
24+
};
25+
in
26+
{
27+
imports = [ ./common/user-account.nix ];
28+
29+
# Workaround ".gala-wrapped invoked oom-killer"
30+
virtualisation.memorySize = 2047;
31+
32+
services.xserver.enable = true;
33+
services.xserver.desktopManager.pantheon.enable = true;
34+
services.displayManager = {
35+
autoLogin.enable = true;
36+
autoLogin.user = nodes.machine.users.users.alice.name;
37+
defaultSession = "pantheon-wayland";
38+
};
39+
40+
# We ship pantheon.appcenter by default when this is enabled.
41+
services.flatpak.enable = true;
42+
43+
# For basic OCR tests.
44+
environment.systemPackages = [ videosAutostart ];
45+
46+
# We don't ship gnome-text-editor in Pantheon module, we add this line mainly
47+
# to catch eval issues related to this option.
48+
environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];
49+
};
50+
51+
enableOCR = true;
52+
53+
testScript =
54+
{ nodes, ... }:
55+
let
56+
user = nodes.machine.users.users.alice;
57+
in
58+
''
59+
machine.wait_for_unit("display-manager.service")
60+
61+
with subtest("Wait for wayland server"):
62+
machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")
63+
64+
with subtest("Check that logging in has given the user ownership of devices"):
65+
machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")
66+
67+
with subtest("Check if Pantheon components actually start"):
68+
# We specifically check gsd-xsettings here since it is manually pulled up by gala.
69+
# https://github.com/elementary/gala/pull/2140
70+
for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "gsd-xsettings", "io.elementary.desktop.agent-polkit"]:
71+
machine.wait_until_succeeds(f"pgrep -f {i}")
72+
for i in ["io.elementary.files.xdg-desktop-portal.service"]:
73+
machine.wait_for_unit(i, "${user.name}")
74+
75+
with subtest("Check if various environment variables are set"):
76+
cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
77+
machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
78+
machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
79+
# Hopefully from the sessionPath option.
80+
machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
81+
# Hopefully from login shell.
82+
machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
83+
84+
with subtest("Wait for elementary videos autostart"):
85+
machine.wait_until_succeeds("pgrep -f io.elementary.videos")
86+
machine.wait_for_text("No Videos Open")
87+
machine.screenshot("videos")
88+
89+
with subtest("Trigger multitasking view"):
90+
cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
91+
env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"
92+
machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
93+
machine.sleep(5)
94+
machine.screenshot("multitasking")
95+
machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
96+
97+
with subtest("Check if gala has ever coredumped"):
98+
machine.fail("coredumpctl --json=short | grep gala")
99+
# So we can see the dock.
100+
machine.execute("pkill -f -9 io.elementary.videos")
101+
machine.sleep(10)
102+
machine.screenshot("screen")
103+
'';
104+
}
105+
)

0 commit comments

Comments
 (0)