2024-08-03 16:27:11 +02:00
|
|
|
use mpvipc_async::{MpvError, MpvExt};
|
2024-05-03 22:29:29 +02:00
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
#[cfg(target_family = "unix")]
|
2024-05-04 13:49:26 +02:00
|
|
|
async fn test_get_mpv_version() -> Result<(), MpvError> {
|
2024-05-03 22:29:29 +02:00
|
|
|
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
2024-05-04 13:49:26 +02:00
|
|
|
let version: String = mpv.get_property("mpv-version").await?.unwrap();
|
2024-05-03 22:29:29 +02:00
|
|
|
assert!(version.starts_with("mpv"));
|
|
|
|
|
|
|
|
mpv.kill().await.unwrap();
|
|
|
|
proc.kill().await.unwrap();
|
2024-05-04 13:49:26 +02:00
|
|
|
|
|
|
|
Ok(())
|
2024-05-03 22:29:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
#[cfg(target_family = "unix")]
|
2024-05-04 13:49:26 +02:00
|
|
|
async fn test_set_property() -> Result<(), MpvError> {
|
2024-05-03 22:29:29 +02:00
|
|
|
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
|
|
|
mpv.set_property("pause", true).await.unwrap();
|
2024-05-04 13:49:26 +02:00
|
|
|
let paused: bool = mpv.get_property("pause").await?.unwrap();
|
2024-05-03 22:29:29 +02:00
|
|
|
assert!(paused);
|
|
|
|
|
|
|
|
mpv.kill().await.unwrap();
|
|
|
|
proc.kill().await.unwrap();
|
2024-05-04 13:49:26 +02:00
|
|
|
|
|
|
|
Ok(())
|
2024-05-04 00:06:22 +02:00
|
|
|
}
|
2024-05-05 13:20:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
#[cfg(target_family = "unix")]
|
|
|
|
async fn test_get_unavailable_property() -> Result<(), MpvError> {
|
|
|
|
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
|
|
|
let time_pos = mpv.get_property::<f64>("time-pos").await;
|
|
|
|
assert_eq!(time_pos, Ok(None));
|
|
|
|
|
|
|
|
mpv.kill().await.unwrap();
|
|
|
|
proc.kill().await.unwrap();
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
#[cfg(target_family = "unix")]
|
|
|
|
async fn test_get_nonexistent_property() -> Result<(), MpvError> {
|
|
|
|
let (mut proc, mpv) = spawn_headless_mpv().await.unwrap();
|
|
|
|
let nonexistent = mpv.get_property::<f64>("nonexistent").await;
|
|
|
|
assert_eq!(nonexistent, Err(MpvError::MpvError("property not found".to_string())));
|
|
|
|
|
|
|
|
mpv.kill().await.unwrap();
|
|
|
|
proc.kill().await.unwrap();
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|