diff --git a/tests/integration_tests/highlevel_api.rs b/tests/integration_tests/highlevel_api.rs new file mode 100644 index 0000000..de9574d --- /dev/null +++ b/tests/integration_tests/highlevel_api.rs @@ -0,0 +1,35 @@ +use super::util::{get_test_asset, spawn_mpv}; + +use mpvipc_async::{ + MpvError, MpvExt, PlaylistAddOptions, PlaylistAddTypeOptions, SeekOptions, Switch, +}; + +#[tokio::test] +#[cfg(target_family = "unix")] +async fn test_seek() -> Result<(), MpvError> { + let (mut proc, mpv) = spawn_mpv(false).await.unwrap(); + mpv.playlist_add( + &get_test_asset("black-background-30s-480p.mp4"), + PlaylistAddTypeOptions::File, + PlaylistAddOptions::Append, + ) + .await?; + + mpv.set_playback(Switch::On).await?; + mpv.set_playback(Switch::Off).await?; + + // TODO: wait for property "seekable" to be true + + mpv.seek(10.0, SeekOptions::Relative).await?; + let time_pos: f64 = mpv.get_property("time-pos").await?.unwrap(); + assert_eq!(time_pos, 10.0); + + mpv.seek(5.0, SeekOptions::Relative).await?; + let time_pos: f64 = mpv.get_property("time-pos").await?.unwrap(); + assert_eq!(time_pos, 15.0); + + mpv.kill().await.unwrap(); + proc.kill().await.unwrap(); + + Ok(()) +} diff --git a/tests/integration_tests/mod.rs b/tests/integration_tests/mod.rs index 2cfc348..b5c16cd 100644 --- a/tests/integration_tests/mod.rs +++ b/tests/integration_tests/mod.rs @@ -1,4 +1,5 @@ mod event_property_parser; +mod highlevel_api; mod misc; mod util;