1let
2 tests = {
3 wayland = { pkgs, ... }: {
4 imports = [ ./common/wayland-cage.nix ];
5
6 services.cage.program = "${pkgs.vscodium}/bin/codium";
7
8 environment.variables.NIXOS_OZONE_WL = "1";
9 environment.variables.DISPLAY = "do not use";
10
11 fonts.fonts = with pkgs; [ dejavu_fonts ];
12 };
13 xorg = { pkgs, ... }: {
14 imports = [ ./common/user-account.nix ./common/x11.nix ];
15
16 virtualisation.memorySize = 2047;
17 services.xserver.enable = true;
18 services.xserver.displayManager.sessionCommands = ''
19 ${pkgs.vscodium}/bin/codium
20 '';
21 test-support.displayManager.auto.user = "alice";
22 };
23 };
24
25 mkTest = name: machine:
26 import ./make-test-python.nix ({ pkgs, ... }: {
27 inherit name;
28
29 nodes = { "${name}" = machine; };
30
31 meta = with pkgs.lib.maintainers; {
32 maintainers = [ synthetica turion ];
33 };
34 enableOCR = true;
35
36 testScript = ''
37 @polling_condition
38 def codium_running():
39 machine.succeed('pgrep -x codium')
40
41
42 start_all()
43
44 machine.wait_for_unit('graphical.target')
45
46 codium_running.wait() # type: ignore[union-attr]
47 with codium_running: # type: ignore[union-attr]
48 # Wait until vscodium is visible. "File" is in the menu bar.
49 machine.wait_for_text('Welcome')
50 machine.screenshot('start_screen')
51
52 test_string = 'testfile'
53
54 # Create a new file
55 machine.send_key('ctrl-n')
56 machine.wait_for_text('Untitled')
57 machine.screenshot('empty_editor')
58
59 # Type a string
60 machine.send_chars(test_string)
61 machine.wait_for_text(test_string)
62 machine.screenshot('editor')
63
64 # Save the file
65 machine.send_key('ctrl-s')
66 machine.wait_for_text('(Save|Desktop|alice|Size)')
67 machine.screenshot('save_window')
68 machine.send_key('ret')
69
70 # (the default filename is the first line of the file)
71 machine.wait_for_file(f'/home/alice/{test_string}')
72
73 # machine.send_key('ctrl-q')
74 # machine.wait_until_fails('pgrep -x codium')
75 '';
76 });
77
78in
79builtins.mapAttrs (k: v: mkTest k v { }) tests