#![cfg(test)]
#![allow(
clippy::unwrap_used,
clippy::expect_used,
clippy::print_stderr,
reason = "unit tests"
)]
use super::*;
#[test]
fn loopback_and_process_loopback_are_not_implemented() {
for kind in [DeviceKind::Loopback, DeviceKind::ProcessLoopback] {
assert_eq!(
support(kind),
Support::Unavailable(Unavailable::NotImplemented)
);
assert_eq!(request_permission(kind), Ok(PermissionState::NotSupported));
}
}
#[test]
fn screen_support_or_skip() {
match support(DeviceKind::Screen) {
Support::Supported => {}
other => eprintln!("skip: screen portal unavailable here ({other:?})"),
}
}
#[test]
fn screen_permission_probe_or_skip() {
match request_permission(DeviceKind::Screen) {
Ok(state) => eprintln!("screen permission probe: {state:?}"),
Err(e) => eprintln!("skip: screen permission probe failed ({e:?})"),
}
}
#[test]
fn window_support_or_skip() {
match support(DeviceKind::Window) {
Support::Supported => {}
other => eprintln!("skip: window portal unavailable here ({other:?})"),
}
}
#[test]
fn window_permission_probe_or_skip() {
match request_permission(DeviceKind::Window) {
Ok(state) => eprintln!("window permission probe: {state:?}"),
Err(e) => eprintln!("skip: window permission probe failed ({e:?})"),
}
}
#[test]
fn camera_support_or_skip() {
match support(DeviceKind::Camera) {
Support::Supported => {}
other => eprintln!("skip: no camera devices found ({other:?})"),
}
}
#[test]
fn camera_permission_probe_or_skip() {
match request_permission(DeviceKind::Camera) {
Ok(state) => eprintln!("camera permission probe: {state:?}"),
Err(e) => eprintln!("skip: camera permission probe failed ({e:?})"),
}
}
#[test]
fn microphone_support_or_skip() {
match support(DeviceKind::Microphone) {
Support::Supported => {}
other => eprintln!("skip: PipeWire daemon unavailable here ({other:?})"),
}
}
#[test]
fn microphone_permission_probe_or_skip() {
match request_permission(DeviceKind::Microphone) {
Ok(state) => eprintln!("microphone permission probe: {state:?}"),
Err(e) => eprintln!("skip: microphone permission probe failed ({e:?})"),
}
}