2020-12-31 05:47:54 +00:00
|
|
|
#![cfg(feature = "test-integration")]
|
|
|
|
|
|
|
|
use std::path::Path;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
use anyhow::Result;
|
|
|
|
use futures_util::{pin_mut, StreamExt};
|
|
|
|
use obws::events::{Event, EventType};
|
|
|
|
use tokio::time;
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
mod common;
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
let client = common::new_client().await?;
|
2021-03-11 11:42:45 +00:00
|
|
|
let events = client.events()?;
|
2020-12-31 05:47:54 +00:00
|
|
|
let client = client.recording();
|
|
|
|
|
|
|
|
pin_mut!(events);
|
|
|
|
|
2021-02-15 11:39:26 +00:00
|
|
|
client.get_recording_status().await?;
|
|
|
|
|
2020-12-31 05:47:54 +00:00
|
|
|
client.start_stop_recording().await?;
|
2021-02-15 11:39:26 +00:00
|
|
|
wait_for!(events, EventType::RecordingStarted { .. });
|
2020-12-31 05:47:54 +00:00
|
|
|
client.start_stop_recording().await?;
|
2021-02-15 11:39:26 +00:00
|
|
|
wait_for!(events, EventType::RecordingStopped { .. });
|
2020-12-31 05:47:54 +00:00
|
|
|
|
|
|
|
// Wait a little more as recording sometimes doesn't start when started/stopped frequently.
|
|
|
|
time::sleep(Duration::from_secs(1)).await;
|
|
|
|
|
|
|
|
client.start_recording().await?;
|
2021-02-15 11:39:26 +00:00
|
|
|
wait_for!(events, EventType::RecordingStarted { .. });
|
2020-12-31 05:47:54 +00:00
|
|
|
// Pausing doesn't seem to work currently
|
|
|
|
// client.pause_recording().await?;
|
|
|
|
// wait_for!(events, EventType::RecordingPaused);
|
|
|
|
// client.resume_recording().await?;
|
|
|
|
// wait_for!(events, EventType::RecordingResumed);
|
|
|
|
client.stop_recording().await?;
|
2021-02-15 11:39:26 +00:00
|
|
|
wait_for!(events, EventType::RecordingStopped { .. });
|
2020-12-31 05:47:54 +00:00
|
|
|
|
|
|
|
let original = client.get_recording_folder().await?;
|
|
|
|
client.set_recording_folder(Path::new("test")).await?;
|
|
|
|
client.set_recording_folder(&original).await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|