summaryrefslogtreecommitdiffstats
path: root/nixos/tests/wmderland.nix
blob: 4ce99b8895212460b5630d211b291b1edd3cd404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ pkgs, ... }:
{
  name = "wmderland";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ takagiy ];
  };

  nodes.machine =
    { lib, ... }:
    {
      imports = [
        ./common/x11.nix
        ./common/user-account.nix
      ];
      test-support.displayManager.auto.user = "alice";
      services.displayManager.defaultSession = lib.mkForce "none+wmderland";
      services.xserver.windowManager.wmderland.enable = true;

      systemd.services.setupWmderlandConfig = {
        wantedBy = [ "multi-user.target" ];
        before = [ "multi-user.target" ];
        environment = {
          HOME = "/home/alice";
        };
        unitConfig = {
          type = "oneshot";
          RemainAfterExit = true;
          user = "alice";
        };
        script =
          let
            config = pkgs.writeText "config" ''
              set $Mod = Mod1
              bindsym $Mod+Return exec ${pkgs.xterm}/bin/xterm -cm -pc
            '';
          in
          ''
            mkdir -p $HOME/.config/wmderland
            cp ${config} $HOME/.config/wmderland/config
          '';
      };
    };

  testScript =
    { ... }:
    ''
      with subtest("ensure x starts"):
          machine.wait_for_x()
          machine.wait_for_file("/home/alice/.Xauthority")
          machine.succeed("xauth merge ~alice/.Xauthority")

      with subtest("ensure we can open a new terminal"):
          machine.send_key("alt-ret")
          machine.wait_until_succeeds("pgrep xterm")
          machine.wait_for_window(r"alice.*?machine")
          machine.screenshot("terminal")

      with subtest("ensure we can communicate through ipc with wmderlandc"):
          # Kills the previously open xterm
          machine.succeed("pgrep xterm")
          machine.execute("DISPLAY=:0 wmderlandc kill")
          machine.fail("pgrep xterm")
    '';
}