Files
arthur-os/test/shell.d/screenrecording-test.sh
T

79 lines
2.1 KiB
Bash

#!/bin/bash
set -euo pipefail
source "$(dirname "$0")/base-test.sh"
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"' EXIT
stub_bin="$tmp_dir/bin"
mkdir -p "$stub_bin"
cat >"$stub_bin/v4l2-ctl" <<'SH'
#!/bin/bash
printf '%s\n' "Built-in Webcam: Integrated Camera"
printf '\t%s\n' "/dev/video0"
printf '\t%s\n' "/dev/video1"
printf '\n'
printf '%s\n' "USB Capture Card: External Camera"
printf '\t%s\n' "/dev/video2"
SH
cat >"$stub_bin/omarchy-menu-select" <<'SH'
#!/bin/bash
printf '%s\n' "$@" >"$OMARCHY_TEST_MENU_ARGS"
printf '%s\n' "$3"
SH
cat >"$stub_bin/omarchy-capture-screenrecording" <<'SH'
#!/bin/bash
printf '%s\n' "$@" >"$OMARCHY_TEST_RECORDER_ARGS"
SH
cat >"$stub_bin/omarchy-notification-send" <<'SH'
#!/bin/bash
printf '%s\n' "$@" >"$OMARCHY_TEST_NOTIFICATION_ARGS"
SH
chmod +x "$stub_bin"/*
export PATH="$stub_bin:$ROOT/bin:$PATH"
export OMARCHY_TEST_MENU_ARGS="$tmp_dir/menu-args"
export OMARCHY_TEST_RECORDER_ARGS="$tmp_dir/recorder-args"
export OMARCHY_TEST_NOTIFICATION_ARGS="$tmp_dir/notification-args"
"$ROOT/bin/omarchy-capture-screenrecording-with-webcam"
expected_menu_args="$tmp_dir/expected-menu-args"
printf '%s\n' \
"Select Webcam" \
"/dev/video0 Built-in Webcam: Integrated Camera" \
"/dev/video2 USB Capture Card: External Camera" \
"--" \
"--width" \
"520" \
"--maxheight" \
"520" >"$expected_menu_args"
if ! cmp -s "$OMARCHY_TEST_MENU_ARGS" "$expected_menu_args"; then
fail "screenrecording webcam picker passes each webcam as a menu option" "$(diff -u "$expected_menu_args" "$OMARCHY_TEST_MENU_ARGS")"
fi
pass "screenrecording webcam picker passes each webcam as a menu option"
expected_recorder_args="$tmp_dir/expected-recorder-args"
printf '%s\n' \
"--with-desktop-audio" \
"--with-microphone-audio" \
"--with-webcam" \
"--webcam-device=/dev/video2" >"$expected_recorder_args"
if ! cmp -s "$OMARCHY_TEST_RECORDER_ARGS" "$expected_recorder_args"; then
fail "screenrecording webcam picker starts recording with selected device" "$(diff -u "$expected_recorder_args" "$OMARCHY_TEST_RECORDER_ARGS")"
fi
pass "screenrecording webcam picker starts recording with selected device"