diff options
| author | Craig Jennings <c@cjennings.net> | 2026-02-26 17:46:11 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-02-26 17:46:11 -0600 |
| commit | 46af687f2444754657000116178eeb80addd5a52 (patch) | |
| tree | 8ccbf758ad9ce58fedd149dec06508b1b860c7bd /tests/test-video-audio-recording--get-available-sinks.el | |
| parent | c43805f86a6f6b87a3f75ab8ece2610905344ec9 (diff) | |
feat(recording): show sinks with active audio indicators in quick-setup
Quick-setup (C-; r s) is now a two-step flow: pick a mic, then pick an
audio output sink. Sinks display / icons with green/dim coloring to
indicate which have active audio streams, with active sinks sorted to
the top. The chosen sink's .monitor is set as the system audio device.
This replaces the old auto-default-sink approach, letting users see
where audio is actually going and pick the right sink in one command.
Diffstat (limited to 'tests/test-video-audio-recording--get-available-sinks.el')
| -rw-r--r-- | tests/test-video-audio-recording--get-available-sinks.el | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/test-video-audio-recording--get-available-sinks.el b/tests/test-video-audio-recording--get-available-sinks.el new file mode 100644 index 00000000..540c4f0f --- /dev/null +++ b/tests/test-video-audio-recording--get-available-sinks.el @@ -0,0 +1,80 @@ +;;; test-video-audio-recording--get-available-sinks.el --- Tests for sink discovery -*- lexical-binding: t; -*- + +;;; Commentary: +;; Unit tests for cj/recording--get-available-sinks. +;; Verifies that available sinks are discovered correctly: +;; - Muted sinks are excluded +;; - Friendly descriptions from PulseAudio are used + +;;; Code: + +(require 'ert) + +;; Stub dependencies before loading the module +(defvar cj/custom-keymap (make-sparse-keymap) + "Stub keymap for testing.") + +(require 'video-audio-recording) + +;;; Helper + +(defun test-sinks--make-pactl-output (sinks) + "Build fake `pactl list sinks' output from SINKS. +Each sink is (name description mute state)." + (mapconcat (lambda (s) + (format "Sink #1\n\tState: %s\n\tName: %s\n\tDescription: %s\n\tMute: %s\n" + (nth 3 s) (nth 0 s) (nth 1 s) (nth 2 s))) + sinks "")) + +;;; Normal Cases + +(ert-deftest test-get-available-sinks-normal-filters-muted () + "Test that muted sinks are excluded from sink list." + (cl-letf (((symbol-function 'shell-command-to-string) + (lambda (_cmd) + (test-sinks--make-pactl-output + '(("active-sink" "Active Sink" "no" "RUNNING") + ("muted-sink" "Muted Sink" "yes" "SUSPENDED")))))) + (let ((sinks (cj/recording--get-available-sinks))) + (should (= 1 (length sinks))) + (should (equal "active-sink" (car (car sinks))))))) + +(ert-deftest test-get-available-sinks-normal-uses-descriptions () + "Test that friendly descriptions are returned as cdr." + (cl-letf (((symbol-function 'shell-command-to-string) + (lambda (_cmd) + (test-sinks--make-pactl-output + '(("raw-sink-name" "Friendly Sink Name" "no" "IDLE")))))) + (let ((sinks (cj/recording--get-available-sinks))) + (should (equal "Friendly Sink Name" (cdr (car sinks))))))) + +(ert-deftest test-get-available-sinks-normal-multiple-sinks () + "Test that multiple non-muted sinks are returned." + (cl-letf (((symbol-function 'shell-command-to-string) + (lambda (_cmd) + (test-sinks--make-pactl-output + '(("sink-a" "JDS Labs" "no" "RUNNING") + ("sink-b" "Shure MV7+" "no" "SUSPENDED") + ("muted-sink" "Muted" "yes" "SUSPENDED")))))) + (let ((sinks (cj/recording--get-available-sinks))) + (should (= 2 (length sinks)))))) + +;;; Boundary Cases + +(ert-deftest test-get-available-sinks-boundary-empty-output () + "Test that empty pactl output returns empty list." + (cl-letf (((symbol-function 'shell-command-to-string) + (lambda (_cmd) ""))) + (should (null (cj/recording--get-available-sinks))))) + +(ert-deftest test-get-available-sinks-boundary-all-muted () + "Test that if all sinks are muted, returns empty list." + (cl-letf (((symbol-function 'shell-command-to-string) + (lambda (_cmd) + (test-sinks--make-pactl-output + '(("muted-a" "Sink A" "yes" "SUSPENDED") + ("muted-b" "Sink B" "yes" "SUSPENDED")))))) + (should (null (cj/recording--get-available-sinks))))) + +(provide 'test-video-audio-recording--get-available-sinks) +;;; test-video-audio-recording--get-available-sinks.el ends here |
