mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Add tests for Element::foreach_pad() and Bus::set_sync_handler()
This commit is contained in:
parent
5625a75b1b
commit
49c5fa33ba
2 changed files with 44 additions and 0 deletions
|
@ -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!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue