diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-05 07:07:04 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-05 07:07:04 -0500 |
| commit | a303c1c8274fc86383365c9de94e7975fb4b0a23 (patch) | |
| tree | 2ec83b8090c5684797cc2fd617d06230eaad12d8 /tests/test-video-audio-recording--device-sort-key.el | |
| parent | 4fa136a0f8bfde7852655a9fce2c44422bd32b3a (diff) | |
test(recording): add direct tests for device-sort-key, device-status-label, get-sink-index
Previously tested only indirectly via label-devices and sink-has-active-audio-p.
Diffstat (limited to 'tests/test-video-audio-recording--device-sort-key.el')
| -rw-r--r-- | tests/test-video-audio-recording--device-sort-key.el | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test-video-audio-recording--device-sort-key.el b/tests/test-video-audio-recording--device-sort-key.el new file mode 100644 index 00000000..97e67747 --- /dev/null +++ b/tests/test-video-audio-recording--device-sort-key.el @@ -0,0 +1,63 @@ +;;; test-video-audio-recording--device-sort-key.el --- Tests for device sort key -*- lexical-binding: t; -*- + +;;; Commentary: +;; Unit tests for cj/recording--device-sort-key. +;; Verifies numeric sort key assignment: RUNNING=0, IDLE=1, SUSPENDED=2, muted=3. + +;;; Code: + +(require 'ert) + +;; Stub dependencies before loading the module +(defvar cj/custom-keymap (make-sparse-keymap) + "Stub keymap for testing.") + +(require 'video-audio-recording) + +;;; Normal Cases + +(ert-deftest test-video-audio-recording--device-sort-key-normal-running () + "RUNNING unmuted device returns 0 (highest priority)." + (should (= 0 (cj/recording--device-sort-key "RUNNING" "no")))) + +(ert-deftest test-video-audio-recording--device-sort-key-normal-idle () + "IDLE unmuted device returns 1." + (should (= 1 (cj/recording--device-sort-key "IDLE" "no")))) + +(ert-deftest test-video-audio-recording--device-sort-key-normal-suspended () + "SUSPENDED unmuted device returns 2." + (should (= 2 (cj/recording--device-sort-key "SUSPENDED" "no")))) + +(ert-deftest test-video-audio-recording--device-sort-key-normal-muted-overrides-state () + "Muted device returns 3 regardless of state." + (should (= 3 (cj/recording--device-sort-key "RUNNING" "yes"))) + (should (= 3 (cj/recording--device-sort-key "IDLE" "yes"))) + (should (= 3 (cj/recording--device-sort-key "SUSPENDED" "yes")))) + +;;; Boundary Cases + +(ert-deftest test-video-audio-recording--device-sort-key-boundary-nil-state () + "Nil state with unmuted returns 2 (default/available)." + (should (= 2 (cj/recording--device-sort-key nil "no")))) + +(ert-deftest test-video-audio-recording--device-sort-key-boundary-lowercase-state () + "Lowercase state is handled via upcase." + (should (= 0 (cj/recording--device-sort-key "running" "no"))) + (should (= 1 (cj/recording--device-sort-key "idle" "no")))) + +(ert-deftest test-video-audio-recording--device-sort-key-boundary-empty-state () + "Empty string state returns 2 (default)." + (should (= 2 (cj/recording--device-sort-key "" "no")))) + +;;; Error Cases + +(ert-deftest test-video-audio-recording--device-sort-key-error-unknown-state () + "Unknown state string returns 2 (falls through to default)." + (should (= 2 (cj/recording--device-sort-key "BOGUS" "no")))) + +(ert-deftest test-video-audio-recording--device-sort-key-error-muted-nil-state () + "Muted with nil state still returns 3 (muted check is first)." + (should (= 3 (cj/recording--device-sort-key nil "yes")))) + +(provide 'test-video-audio-recording--device-sort-key) +;;; test-video-audio-recording--device-sort-key.el ends here |
