lol

nixosTests.cinnamon: Extend the test

+38 -22
+38 -22
nixos/tests/cinnamon.nix
··· 14 14 testScript = { nodes, ... }: 15 15 let 16 16 user = nodes.machine.users.users.alice; 17 - uid = toString user.uid; 18 - bus = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${uid}/bus"; 19 - display = "DISPLAY=:0.0"; 20 - env = "${bus} ${display}"; 21 - gdbus = "${env} gdbus"; 17 + env = "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${toString user.uid}/bus DISPLAY=:0"; 22 18 su = command: "su - ${user.name} -c '${env} ${command}'"; 23 19 24 20 # Call javascript in cinnamon (the shell), returns a tuple (success, output), 25 21 # where `success` is true if the dbus call was successful and `output` is what 26 22 # the javascript evaluates to. 27 - eval = "call --session -d org.Cinnamon -o /org/Cinnamon -m org.Cinnamon.Eval"; 28 - 29 - # Should be 2 (RunState.RUNNING) when startup is done. 30 - # https://github.com/linuxmint/cinnamon/blob/5.4.0/js/ui/main.js#L183-L187 31 - getRunState = su "${gdbus} ${eval} Main.runState"; 32 - 33 - # Start gnome-terminal. 34 - gnomeTerminalCommand = su "gnome-terminal"; 35 - 36 - # Hopefully gnome-terminal's wm class. 37 - wmClass = su "${gdbus} ${eval} global.display.focus_window.wm_class"; 23 + eval = name: su "gdbus call --session -d org.Cinnamon -o /org/Cinnamon -m org.Cinnamon.Eval ${name}"; 38 24 in 39 25 '' 40 26 machine.wait_for_unit("display-manager.service") ··· 54 40 55 41 with subtest("Wait for the Cinnamon shell"): 56 42 # Correct output should be (true, '2') 57 - machine.wait_until_succeeds("${getRunState} | grep -q 'true,..2'") 43 + # https://github.com/linuxmint/cinnamon/blob/5.4.0/js/ui/main.js#L183-L187 44 + machine.wait_until_succeeds("${eval "Main.runState"} | grep -q 'true,..2'") 45 + 46 + with subtest("Check if Cinnamon components actually start"): 47 + for i in ["csd-media-keys", "cinnamon-killer-daemon", "xapp-sn-watcher", "nemo-desktop"]: 48 + machine.wait_until_succeeds(f"pgrep -f {i}") 49 + machine.wait_until_succeeds("journalctl -b --grep 'Loaded applet menu@cinnamon.org'") 50 + machine.wait_until_succeeds("journalctl -b --grep 'calendar@cinnamon.org: Calendar events supported'") 51 + 52 + with subtest("Open Cinnamon Settings"): 53 + machine.succeed("${su "cinnamon-settings themes >&2 &"}") 54 + machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'cinnamon-settings'") 55 + machine.wait_for_text('(Style|Appearance|Color)') 56 + machine.sleep(2) 57 + machine.screenshot("cinnamon_settings") 58 + 59 + with subtest("Lock the screen"): 60 + machine.succeed("${su "cinnamon-screensaver-command -l >&2 &"}") 61 + machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is active'") 62 + machine.sleep(2) 63 + machine.screenshot("cinnamon_screensaver") 64 + machine.send_chars("${user.password}\n", delay=0.2) 65 + machine.wait_until_succeeds("${su "cinnamon-screensaver-command -q"} | grep 'The screensaver is inactive'") 66 + machine.sleep(2) 58 67 59 68 with subtest("Open GNOME Terminal"): 60 - machine.succeed("${gnomeTerminalCommand}") 61 - # Correct output should be (true, '"Gnome-terminal"') 62 - machine.wait_until_succeeds("${wmClass} | grep -q 'true,...Gnome-terminal'") 63 - machine.sleep(20) 64 - machine.screenshot("screen") 69 + machine.succeed("${su "gnome-terminal"}") 70 + machine.wait_until_succeeds("${eval "global.display.focus_window.wm_class"} | grep -i 'gnome-terminal'") 71 + machine.sleep(2) 72 + 73 + with subtest("Open virtual keyboard"): 74 + machine.succeed("${su "dbus-send --print-reply --dest=org.Cinnamon /org/Cinnamon org.Cinnamon.ToggleKeyboard"}") 75 + machine.wait_for_text('(Ctrl|Alt)') 76 + machine.sleep(2) 77 + machine.screenshot("cinnamon_virtual_keyboard") 78 + 79 + with subtest("Check if Cinnamon has ever coredumped"): 80 + machine.fail("coredumpctl --json=short | grep -E 'cinnamon|nemo'") 65 81 ''; 66 82 })