From 6263922b6d16b4abb7fc0193ad1c72c6c268cb5b Mon Sep 17 00:00:00 2001 From: Valmir Pretto Date: Thu, 30 Jan 2020 09:30:17 -0300 Subject: [PATCH] gstreamer: BusStream tests --- gstreamer/Cargo.toml | 1 + gstreamer/src/bus.rs | 19 +++++++++++++++++++ gstreamer/src/lib.rs | 3 +++ 3 files changed, 23 insertions(+) diff --git a/gstreamer/Cargo.toml b/gstreamer/Cargo.toml index 4228a6e27..224b400af 100644 --- a/gstreamer/Cargo.toml +++ b/gstreamer/Cargo.toml @@ -39,6 +39,7 @@ rustdoc-stripper = { version = "0.1", optional = true } [dev-dependencies] ron = "0.5" serde_json = "1.0" +futures-executor = "0.3.1" [features] default = [] diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 96b3c8420..7447e83bb 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -312,4 +312,23 @@ mod tests { _ => unreachable!(), } } + + #[test] + fn test_bus_stream() { + ::init().unwrap(); + + let bus = Bus::new(); + let bus_stream = bus.stream(); + + let eos_message = ::Message::new_eos().build(); + bus.post(&eos_message).unwrap(); + + let bus_future = bus_stream.into_future(); + let (message, _) = futures_executor::block_on(bus_future); + + match message.unwrap().view() { + ::MessageView::Eos(_) => (), + _ => unreachable!(), + } + } } diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index e2fd59c59..fd85a7f4f 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -48,6 +48,9 @@ extern crate serde_bytes; #[macro_use] extern crate serde_derive; +#[cfg(test)] +extern crate futures_executor; + use glib::translate::{from_glib, from_glib_full}; macro_rules! assert_initialized_main_thread {