diff options
| author | Craig Jennings <c@cjennings.net> | 2026-02-06 13:00:01 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-02-06 13:12:44 -0600 |
| commit | c603124f6487604baee5aab590e1432e99570ca8 (patch) | |
| tree | 85c8b3ac4dc0573b1aee4448c1ae7d2c21ce3225 /tests/test-video-audio-recording-get-devices.el | |
| parent | 25a2acb634212455abeb0a0c8fb1a97c3ece3a2c (diff) | |
feat(recording): rewrite device setup, fix video stop, update modeline icons
Video stop fix: kill wf-recorder (producer) first on Wayland so ffmpeg
gets clean EOF, then signal process group. Replaces sit-for with
poll-based wait-for-exit. Fixes zero-byte output files.
Device selection: rewrite quick setup to show all available mics with
PulseAudio descriptions, auto-detect default sink monitor for system
audio. Skip confirmation dialog, add Cancel option to mic list.
Modeline: replace red dot emoji with nerd font icons (mic/camcorder).
Rename quick-setup-for-calls to quick-setup, rebind C-; r s / C-; r S.
173 recording tests pass (was 165).
Diffstat (limited to 'tests/test-video-audio-recording-get-devices.el')
| -rw-r--r-- | tests/test-video-audio-recording-get-devices.el | 95 |
1 files changed, 21 insertions, 74 deletions
diff --git a/tests/test-video-audio-recording-get-devices.el b/tests/test-video-audio-recording-get-devices.el index ba7d95b9..0af02bb3 100644 --- a/tests/test-video-audio-recording-get-devices.el +++ b/tests/test-video-audio-recording-get-devices.el @@ -4,9 +4,8 @@ ;; Unit tests for cj/recording-get-devices function. ;; Tests device prompting and validation workflow. ;; -;; NOTE: This function was refactored to use interactive prompts instead of -;; auto-detection. It now prompts the user with y-or-n-p and calls either -;; cj/recording-quick-setup-for-calls or cj/recording-select-devices. +;; NOTE: This function goes straight into quick setup (mic selection) +;; when devices aren't configured — no confirmation dialog. ;;; Code: @@ -46,29 +45,12 @@ (should (equal "preset-monitor" (cdr result))))) (test-get-devices-teardown))) -(ert-deftest test-video-audio-recording-get-devices-normal-prompts-when-not-configured () - "Test that function prompts user when devices not configured." - (test-get-devices-setup) - (unwind-protect - (let ((prompt-called nil)) - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) (setq prompt-called t) t)) - ((symbol-function 'cj/recording-quick-setup-for-calls) - (lambda () - (setq cj/recording-mic-device "quick-mic") - (setq cj/recording-system-device "quick-monitor")))) - (cj/recording-get-devices) - (should prompt-called))) - (test-get-devices-teardown))) - -(ert-deftest test-video-audio-recording-get-devices-normal-calls-quick-setup-on-yes () - "Test that function calls quick setup when user answers yes." +(ert-deftest test-video-audio-recording-get-devices-normal-calls-quick-setup () + "Test that function calls quick setup when devices not configured." (test-get-devices-setup) (unwind-protect (let ((quick-setup-called nil)) - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) t)) - ((symbol-function 'cj/recording-quick-setup-for-calls) + (cl-letf (((symbol-function 'cj/recording-quick-setup) (lambda () (setq quick-setup-called t) (setq cj/recording-mic-device "quick-mic") @@ -77,29 +59,11 @@ (should quick-setup-called))) (test-get-devices-teardown))) -(ert-deftest test-video-audio-recording-get-devices-normal-calls-select-devices-on-no () - "Test that function calls manual selection when user answers no." - (test-get-devices-setup) - (unwind-protect - (let ((select-called nil)) - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) nil)) - ((symbol-function 'cj/recording-select-devices) - (lambda () - (setq select-called t) - (setq cj/recording-mic-device "manual-mic") - (setq cj/recording-system-device "manual-monitor")))) - (cj/recording-get-devices) - (should select-called))) - (test-get-devices-teardown))) - (ert-deftest test-video-audio-recording-get-devices-normal-returns-cons-cell () "Test that function returns (mic . monitor) cons cell." (test-get-devices-setup) (unwind-protect - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) t)) - ((symbol-function 'cj/recording-quick-setup-for-calls) + (cl-letf (((symbol-function 'cj/recording-quick-setup) (lambda () (setq cj/recording-mic-device "test-mic") (setq cj/recording-system-device "test-monitor")))) @@ -111,40 +75,38 @@ ;;; Boundary Cases -(ert-deftest test-video-audio-recording-get-devices-boundary-only-mic-set-prompts () - "Test that function prompts even when only mic is set." +(ert-deftest test-video-audio-recording-get-devices-boundary-only-mic-set-calls-setup () + "Test that function calls setup even when only mic is set." (test-get-devices-setup) (unwind-protect (progn (setq cj/recording-mic-device "preset-mic") (setq cj/recording-system-device nil) - (let ((prompt-called nil)) - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) (setq prompt-called t) t)) - ((symbol-function 'cj/recording-quick-setup-for-calls) + (let ((quick-setup-called nil)) + (cl-letf (((symbol-function 'cj/recording-quick-setup) (lambda () + (setq quick-setup-called t) (setq cj/recording-mic-device "new-mic") (setq cj/recording-system-device "new-monitor")))) (cj/recording-get-devices) - (should prompt-called)))) + (should quick-setup-called)))) (test-get-devices-teardown))) -(ert-deftest test-video-audio-recording-get-devices-boundary-only-monitor-set-prompts () - "Test that function prompts even when only monitor is set." +(ert-deftest test-video-audio-recording-get-devices-boundary-only-monitor-set-calls-setup () + "Test that function calls setup even when only monitor is set." (test-get-devices-setup) (unwind-protect (progn (setq cj/recording-mic-device nil) (setq cj/recording-system-device "preset-monitor") - (let ((prompt-called nil)) - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) (setq prompt-called t) t)) - ((symbol-function 'cj/recording-quick-setup-for-calls) + (let ((quick-setup-called nil)) + (cl-letf (((symbol-function 'cj/recording-quick-setup) (lambda () + (setq quick-setup-called t) (setq cj/recording-mic-device "new-mic") (setq cj/recording-system-device "new-monitor")))) (cj/recording-get-devices) - (should prompt-called)))) + (should quick-setup-called)))) (test-get-devices-teardown))) ;;; Error Cases @@ -153,9 +115,7 @@ "Test that function signals error when setup fails to set devices." (test-get-devices-setup) (unwind-protect - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) t)) - ((symbol-function 'cj/recording-quick-setup-for-calls) + (cl-letf (((symbol-function 'cj/recording-quick-setup) (lambda () nil))) ;; Setup fails - doesn't set devices (should-error (cj/recording-get-devices) :type 'user-error)) (test-get-devices-teardown))) @@ -164,27 +124,14 @@ "Test that error message guides user to setup commands." (test-get-devices-setup) (unwind-protect - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) t)) - ((symbol-function 'cj/recording-quick-setup-for-calls) + (cl-letf (((symbol-function 'cj/recording-quick-setup) (lambda () nil))) (condition-case err (cj/recording-get-devices) (user-error - (should (string-match-p "C-; r c" (error-message-string err))) + (should (string-match-p "C-; r s" (error-message-string err))) (should (string-match-p "C-; r s" (error-message-string err)))))) (test-get-devices-teardown))) -(ert-deftest test-video-audio-recording-get-devices-error-select-devices-fails () - "Test that function signals error when manual selection fails." - (test-get-devices-setup) - (unwind-protect - (cl-letf (((symbol-function 'y-or-n-p) - (lambda (_prompt) nil)) - ((symbol-function 'cj/recording-select-devices) - (lambda () nil))) ;; Manual selection fails - (should-error (cj/recording-get-devices) :type 'user-error)) - (test-get-devices-teardown))) - (provide 'test-video-audio-recording-get-devices) ;;; test-video-audio-recording-get-devices.el ends here |
