summaryrefslogtreecommitdiff
path: root/tests/test-video-audio-recording-get-devices.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-video-audio-recording-get-devices.el')
-rw-r--r--tests/test-video-audio-recording-get-devices.el95
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