Unverified Commit c40ffecc authored by Bobby Rong's avatar Bobby Rong
Browse files

nixos/tests/pantheon: Only test wayland session

This copies the previous pantheon-wayland test to pantheon.
parent b9eea406
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1146,7 +1146,6 @@ in
  patroni = handleTestOn [ "x86_64-linux" ] ./patroni.nix { };
  pantalaimon = runTest ./matrix/pantalaimon.nix;
  pantheon = runTest ./pantheon.nix;
  pantheon-wayland = runTest ./pantheon-wayland.nix;
  paperless = runTest ./paperless.nix;
  parsedmarc = handleTest ./parsedmarc { };
  password-option-override-ordering = runTest ./password-option-override-ordering.nix;

nixos/tests/pantheon-wayland.nix

deleted100644 → 0
+0 −104
Original line number Diff line number Diff line
{ pkgs, lib, ... }:

{
  name = "pantheon-wayland";

  meta.maintainers = lib.teams.pantheon.members;

  nodes.machine =
    { nodes, ... }:

    let
      videosAutostart = pkgs.writeTextFile {
        name = "autostart-elementary-videos";
        destination = "/etc/xdg/autostart/io.elementary.videos.desktop";
        text = ''
          [Desktop Entry]
          Version=1.0
          Name=Videos
          Type=Application
          Terminal=false
          Exec=io.elementary.videos %U
        '';
      };
    in
    {
      imports = [ ./common/user-account.nix ];

      # Workaround ".gala-wrapped invoked oom-killer"
      virtualisation.memorySize = 2047;

      services.xserver.enable = true;
      services.desktopManager.pantheon.enable = true;
      services.displayManager = {
        autoLogin.enable = true;
        autoLogin.user = nodes.machine.users.users.alice.name;
        defaultSession = "pantheon-wayland";
      };

      # We ship pantheon.appcenter by default when this is enabled.
      services.flatpak.enable = true;

      # For basic OCR tests.
      environment.systemPackages = [ videosAutostart ];

      # We don't ship gnome-text-editor in Pantheon module, we add this line mainly
      # to catch eval issues related to this option.
      environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];
    };

  enableOCR = true;

  testScript =
    { nodes, ... }:
    let
      user = nodes.machine.users.users.alice;
    in
    ''
      machine.wait_for_unit("display-manager.service")

      with subtest("Wait for wayland server"):
          machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")

      with subtest("Check that logging in has given the user ownership of devices"):
          machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")

      with subtest("Check if Pantheon components actually start"):
          # We specifically check gsd-xsettings here since it is manually pulled up by gala.
          # https://github.com/elementary/gala/pull/2140
          for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "gsd-xsettings", "io.elementary.desktop.agent-polkit"]:
              machine.wait_until_succeeds(f"pgrep -f {i}")
          machine.wait_until_succeeds("pgrep -xf ${pkgs.pantheon.elementary-files}/libexec/io.elementary.files.xdg-desktop-portal")

      with subtest("Check if various environment variables are set"):
          cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
          machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
          machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
          # Hopefully from the sessionPath option.
          machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
          # Hopefully from login shell.
          machine.succeed(f"{cmd} | grep '__NIXOS_SET_ENVIRONMENT_DONE' | grep '1'")
          # Hopefully from gcr-ssh-agent.
          machine.succeed(f"{cmd} | grep 'SSH_AUTH_SOCK' | grep 'gcr'")

      with subtest("Wait for elementary videos autostart"):
          machine.wait_until_succeeds("pgrep -f io.elementary.videos")
          machine.wait_for_text("No Videos Open")
          machine.screenshot("videos")

      with subtest("Trigger multitasking view"):
          cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
          env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"
          machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
          machine.sleep(5)
          machine.screenshot("multitasking")
          machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")

      with subtest("Check if gala has ever coredumped"):
          machine.fail("coredumpctl --json=short | grep gala")
          # So we can see the dock.
          machine.execute("pkill -f -9 io.elementary.videos")
          machine.sleep(10)
          machine.screenshot("screen")
    '';
}
+35 −47
Original line number Diff line number Diff line
@@ -6,8 +6,22 @@
  meta.maintainers = lib.teams.pantheon.members;

  nodes.machine =
    { ... }:
    { nodes, ... }:

    let
      videosAutostart = pkgs.writeTextFile {
        name = "autostart-elementary-videos";
        destination = "/etc/xdg/autostart/io.elementary.videos.desktop";
        text = ''
          [Desktop Entry]
          Version=1.0
          Name=Videos
          Type=Application
          Terminal=false
          Exec=io.elementary.videos %U
        '';
      };
    in
    {
      imports = [ ./common/user-account.nix ];

@@ -16,15 +30,21 @@

      services.xserver.enable = true;
      services.desktopManager.pantheon.enable = true;
      services.displayManager = {
        autoLogin.enable = true;
        autoLogin.user = nodes.machine.users.users.alice.name;
        defaultSession = "pantheon-wayland";
      };

      # We ship pantheon.appcenter by default when this is enabled.
      services.flatpak.enable = true;

      # For basic OCR tests.
      environment.systemPackages = [ videosAutostart ];

      # We don't ship gnome-text-editor in Pantheon module, we add this line mainly
      # to catch eval issues related to this option.
      environment.pantheon.excludePackages = [ pkgs.gnome-text-editor ];

      environment.systemPackages = [ pkgs.xdotool ];
    };

  enableOCR = true;
@@ -33,42 +53,27 @@
    { nodes, ... }:
    let
      user = nodes.machine.users.users.alice;
      bob = nodes.machine.users.users.bob;
    in
    ''
      machine.wait_for_unit("display-manager.service")

      with subtest("Test we can see usernames in elementary-greeter"):
          machine.wait_for_text("${user.description}")
          machine.wait_until_succeeds("pgrep -f io.elementary.greeter-compositor")
          # OCR was struggling with this one.
          # machine.wait_for_text("${bob.description}")
          # Ensure the password box is focused by clicking it.
          # Workaround for https://github.com/NixOS/nixpkgs/issues/211366.
          machine.succeed("XAUTHORITY=/var/lib/lightdm/.Xauthority DISPLAY=:0 xdotool mousemove 512 505 click 1")
          machine.sleep(2)
          machine.screenshot("elementary_greeter_lightdm")

      with subtest("Login with elementary-greeter"):
          machine.send_chars("${user.password}\n")
          machine.wait_for_x()
          machine.wait_for_file("${user.home}/.Xauthority")
          machine.succeed("xauth merge ${user.home}/.Xauthority")
          machine.wait_until_succeeds('journalctl -t gnome-session-binary --grep "Entering running state"')
      with subtest("Wait for wayland server"):
          machine.wait_for_file("/run/user/${toString user.uid}/wayland-0")

      with subtest("Check that logging in has given the user ownership of devices"):
          machine.succeed("getfacl -p /dev/snd/timer | grep -q ${user.name}")

      with subtest("Check if Pantheon components actually start"):
          for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "io.elementary.desktop.agent-polkit"]:
          # We specifically check gsd-xsettings here since it is manually pulled up by gala.
          # https://github.com/elementary/gala/pull/2140
          for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock", "gsd-media-keys", "gsd-xsettings", "io.elementary.desktop.agent-polkit"]:
              machine.wait_until_succeeds(f"pgrep -f {i}")
          for i in ["gala", "io.elementary.wingpanel", "io.elementary.dock"]:
              machine.wait_for_window(i)
          machine.wait_until_succeeds("pgrep -xf ${pkgs.pantheon.elementary-files}/libexec/io.elementary.files.xdg-desktop-portal")

      with subtest("Check if various environment variables are set"):
          cmd = "xargs --null --max-args=1 echo < /proc/$(pgrep -xf ${pkgs.pantheon.gala}/bin/gala)/environ"
          machine.succeed(f"{cmd} | grep 'XDG_CURRENT_DESKTOP' | grep 'Pantheon'")
          machine.succeed(f"{cmd} | grep 'XDG_SESSION_TYPE' | grep 'wayland'")
          # Hopefully from the sessionPath option.
          machine.succeed(f"{cmd} | grep 'XDG_DATA_DIRS' | grep 'gsettings-schemas/pantheon-agent-geoclue2'")
          # Hopefully from login shell.
@@ -76,31 +81,14 @@
          # Hopefully from gcr-ssh-agent.
          machine.succeed(f"{cmd} | grep 'SSH_AUTH_SOCK' | grep 'gcr'")

      with subtest("Open elementary videos"):
          machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.videos >&2 &'")
          machine.sleep(2)
          machine.wait_for_window("io.elementary.videos")
      with subtest("Wait for elementary videos autostart"):
          machine.wait_until_succeeds("pgrep -f io.elementary.videos")
          machine.wait_for_text("No Videos Open")

      with subtest("Open elementary calendar"):
          machine.wait_until_succeeds("pgrep -f evolution-calendar-factory")
          machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.calendar >&2 &'")
          machine.sleep(2)
          machine.wait_for_window("io.elementary.calendar")

      with subtest("Open system settings"):
          machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.settings >&2 &'")
          # Wait for all plugins to be loaded before we check if the window is still there.
          machine.sleep(5)
          machine.wait_for_window("io.elementary.settings")

      with subtest("Open elementary terminal"):
          machine.execute("su - ${user.name} -c 'DISPLAY=:0 io.elementary.terminal >&2 &'")
          machine.wait_for_window("io.elementary.terminal")
          machine.screenshot("videos")

      with subtest("Trigger multitasking view"):
          cmd = "dbus-send --session --dest=org.pantheon.gala --print-reply /org/pantheon/gala org.pantheon.gala.PerformAction int32:1"
          env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0"
          env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus"
          machine.succeed(f"su - ${user.name} -c '{env} {cmd}'")
          machine.sleep(5)
          machine.screenshot("multitasking")
@@ -108,8 +96,8 @@

      with subtest("Check if gala has ever coredumped"):
          machine.fail("coredumpctl --json=short | grep gala")
          # So you can see the dock in the below screenshot.
          machine.succeed("su - ${user.name} -c 'DISPLAY=:0 xdotool mousemove 450 1000 >&2 &'")
          # So we can see the dock.
          machine.execute("pkill -f -9 io.elementary.videos")
          machine.sleep(10)
          machine.screenshot("screen")
    '';