mirror of https://github.com/dnaka91/obws
Add more integration tests for client requests
parent
5077adac0b
commit
0bdaccbf42
@ -0,0 +1,28 @@
|
||||
#![cfg(feature = "test-integration")]
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::time;
|
||||
|
||||
use common::TEST_PROFILE;
|
||||
|
||||
mod common;
|
||||
|
||||
#[tokio::test]
|
||||
async fn main() -> Result<()> {
|
||||
let client = common::new_client().await?;
|
||||
let client = client.profiles();
|
||||
|
||||
client.list_profiles().await?;
|
||||
|
||||
let original = client.get_current_profile().await?;
|
||||
client.set_current_profile(TEST_PROFILE).await?;
|
||||
|
||||
// Give OBS some time to switch profiles
|
||||
time::sleep(Duration::from_millis(200)).await;
|
||||
|
||||
client.set_current_profile(&original).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
#![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?;
|
||||
let events = client.events();
|
||||
let client = client.recording();
|
||||
|
||||
pin_mut!(events);
|
||||
|
||||
client.start_stop_recording().await?;
|
||||
wait_for!(events, EventType::RecordingStarted);
|
||||
client.start_stop_recording().await?;
|
||||
wait_for!(events, EventType::RecordingStopped);
|
||||
|
||||
// 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?;
|
||||
wait_for!(events, EventType::RecordingStarted);
|
||||
// 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?;
|
||||
wait_for!(events, EventType::RecordingStopped);
|
||||
|
||||
let original = client.get_recording_folder().await?;
|
||||
client.set_recording_folder(Path::new("test")).await?;
|
||||
client.set_recording_folder(&original).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
#![cfg(feature = "test-integration")]
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use tokio::time;
|
||||
|
||||
use common::TEST_COLLECTION;
|
||||
|
||||
mod common;
|
||||
|
||||
#[tokio::test]
|
||||
async fn main() -> Result<()> {
|
||||
let client = common::new_client().await?;
|
||||
let client = client.scene_collections();
|
||||
|
||||
let other = client
|
||||
.list_scene_collections()
|
||||
.await?
|
||||
.into_iter()
|
||||
.find(|sc| sc.sc_name != TEST_COLLECTION)
|
||||
.context("only the test scene collection exists, but another is needed for tests")?
|
||||
.sc_name;
|
||||
|
||||
let original = client.get_current_scene_collection().await?;
|
||||
client.set_current_scene_collection(&other).await?;
|
||||
|
||||
// Give OBS some time to load the scene collection
|
||||
time::sleep(Duration::from_secs(1)).await;
|
||||
|
||||
client.set_current_scene_collection(&original).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in New Issue