test/util: allow tests to run mpv non-headless for debugging
This commit is contained in:
parent
44d7e15fb1
commit
77d4e80eec
@ -115,7 +115,7 @@ async fn graceful_shutdown(
|
||||
#[test(tokio::test)]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_highlevel_event_pause() -> Result<(), MpvError> {
|
||||
let (proc, mpv) = spawn_headless_mpv().await?;
|
||||
let (proc, mpv) = spawn_mpv(true).await?;
|
||||
|
||||
mpv.observe_property(MPV_CHANNEL_ID, "pause").await?;
|
||||
|
||||
@ -144,7 +144,7 @@ async fn test_highlevel_event_pause() -> Result<(), MpvError> {
|
||||
#[test(tokio::test)]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_highlevel_event_volume() -> Result<(), MpvError> {
|
||||
let (proc, mpv) = spawn_headless_mpv().await?;
|
||||
let (proc, mpv) = spawn_mpv(true).await?;
|
||||
|
||||
mpv.observe_property(1337, "volume").await?;
|
||||
let events = mpv.get_event_stream().await;
|
||||
@ -174,7 +174,7 @@ async fn test_highlevel_event_volume() -> Result<(), MpvError> {
|
||||
#[test(tokio::test)]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_highlevel_event_mute() -> Result<(), MpvError> {
|
||||
let (proc, mpv) = spawn_headless_mpv().await?;
|
||||
let (proc, mpv) = spawn_mpv(true).await?;
|
||||
|
||||
mpv.observe_property(1337, "mute").await?;
|
||||
let events = mpv.get_event_stream().await;
|
||||
@ -202,7 +202,7 @@ async fn test_highlevel_event_mute() -> Result<(), MpvError> {
|
||||
#[test(tokio::test)]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_highlevel_event_duration() -> Result<(), MpvError> {
|
||||
let (proc, mpv) = spawn_headless_mpv().await?;
|
||||
let (proc, mpv) = spawn_mpv(true).await?;
|
||||
|
||||
mpv.observe_property(1337, "duration").await?;
|
||||
|
||||
|
@ -5,7 +5,7 @@ use super::*;
|
||||
#[tokio::test]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_get_mpv_version() -> Result<(), MpvError> {
|
||||
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
||||
let (mut proc, mpv) = spawn_mpv(true).await.unwrap();
|
||||
let version: String = mpv.get_property("mpv-version").await?.unwrap();
|
||||
assert!(version.starts_with("mpv"));
|
||||
|
||||
@ -18,7 +18,7 @@ async fn test_get_mpv_version() -> Result<(), MpvError> {
|
||||
#[tokio::test]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_set_property() -> Result<(), MpvError> {
|
||||
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
||||
let (mut proc, mpv) = spawn_mpv(true).await.unwrap();
|
||||
mpv.set_property("pause", true).await.unwrap();
|
||||
let paused: bool = mpv.get_property("pause").await?.unwrap();
|
||||
assert!(paused);
|
||||
@ -32,7 +32,7 @@ async fn test_set_property() -> Result<(), MpvError> {
|
||||
#[tokio::test]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_get_unavailable_property() -> Result<(), MpvError> {
|
||||
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
||||
let (mut proc, mpv) = spawn_mpv(true).await.unwrap();
|
||||
let time_pos = mpv.get_property::<f64>("time-pos").await;
|
||||
assert_eq!(time_pos, Ok(None));
|
||||
|
||||
@ -45,7 +45,7 @@ async fn test_get_unavailable_property() -> Result<(), MpvError> {
|
||||
#[tokio::test]
|
||||
#[cfg(target_family = "unix")]
|
||||
async fn test_get_nonexistent_property() -> Result<(), MpvError> {
|
||||
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
||||
let (mut proc, mpv) = spawn_mpv(true).await.unwrap();
|
||||
let nonexistent = mpv.get_property::<f64>("nonexistent").await;
|
||||
|
||||
match nonexistent {
|
||||
|
@ -34,7 +34,7 @@ pub fn get_test_asset(file_name: &str) -> String {
|
||||
}
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
pub async fn spawn_headless_mpv() -> Result<(Child, Mpv), MpvError> {
|
||||
pub async fn spawn_mpv(headless: bool) -> Result<(Child, Mpv), MpvError> {
|
||||
let socket_path_str = format!("/tmp/mpv-ipc-{}", uuid::Uuid::new_v4());
|
||||
let socket_path = Path::new(&socket_path_str);
|
||||
|
||||
@ -42,8 +42,11 @@ pub async fn spawn_headless_mpv() -> Result<(Child, Mpv), MpvError> {
|
||||
let process_handle = Command::new("mpv")
|
||||
.arg("--no-config")
|
||||
.arg("--idle")
|
||||
.arg("--no-video")
|
||||
.arg("--no-audio")
|
||||
.args(if headless {
|
||||
vec!["--no-video", "--no-audio"]
|
||||
} else {
|
||||
vec![]
|
||||
})
|
||||
.arg(format!(
|
||||
"--input-ipc-server={}",
|
||||
&socket_path.to_str().unwrap()
|
||||
|
Loading…
Reference in New Issue
Block a user