about summary refs log tree commit diff
path: root/nixos/tests/wmderland.nix
blob: ebfd443763e1edec17c016942501f49b6b230d58 (plain) (blame)
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
import ./make-test-python.nix ({ 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.xserver.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")
  '';
})