diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index ca98cff37..cc12b8993 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -223,3 +223,31 @@ mod futures { #[cfg(any(feature = "futures", feature = "dox"))] pub use bus::futures::BusStream; + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::{Arc, Mutex}; + + #[test] + fn test_sync_handler() { + ::init().unwrap(); + + let bus = Bus::new(); + let msgs = Arc::new(Mutex::new(Vec::new())); + let msgs_clone = msgs.clone(); + bus.set_sync_handler(move |_, msg| { + msgs_clone.lock().unwrap().push(msg.clone()); + BusSyncReply::Pass + }); + + bus.post(&::Message::new_eos().build()).unwrap(); + + let msgs = msgs.lock().unwrap(); + assert_eq!(msgs.len(), 1); + match msgs[0].view() { + ::MessageView::Eos(_) => (), + _ => unreachable!(), + } + } +} diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 9f3a3c6bb..3de91cbc3 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -1257,6 +1257,22 @@ mod tests { assert_eq!(pad_names, vec![String::from("src")]); } + #[test] + fn test_foreach_pad() { + ::init().unwrap(); + + let identity = ::ElementFactory::make("identity", None).unwrap(); + + let mut pad_names = Vec::new(); + identity.foreach_pad(|_element, pad| { + pad_names.push(pad.get_name()); + + true + }); + pad_names.sort(); + assert_eq!(pad_names, vec![String::from("sink"), String::from("src")]); + } + #[cfg(feature = "v1_10")] #[test] fn test_call_async() {