Commit f08f0f6f authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add tests for Bin::get_children() and Element::get_*pads()

parent 50c8f329
......@@ -97,3 +97,30 @@ impl<O: IsA<Bin>> BinExtManual for O {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use prelude::*;
#[test]
fn test_get_children() {
::init().unwrap();
let bin = ::Bin::new(None);
bin.add(&::ElementFactory::make("identity", "identity0").unwrap())
.unwrap();
bin.add(&::ElementFactory::make("identity", "identity1").unwrap())
.unwrap();
let mut child_names = bin.get_children()
.iter()
.map(|c| c.get_name())
.collect::<Vec<String>>();
child_names.sort();
assert_eq!(
child_names,
vec![String::from("identity0"), String::from("identity1")]
);
}
}
......@@ -268,3 +268,40 @@ lazy_static!{
pub static ref ELEMENT_METADATA_KLASS: &'static str = unsafe { CStr::from_ptr(ffi::GST_ELEMENT_METADATA_KLASS).to_str().unwrap() };
pub static ref ELEMENT_METADATA_LONGNAME: &'static str = unsafe { CStr::from_ptr(ffi::GST_ELEMENT_METADATA_LONGNAME).to_str().unwrap() };
}
#[cfg(test)]
mod tests {
use super::*;
use prelude::*;
#[test]
fn test_get_pads() {
::init().unwrap();
let identity = ::ElementFactory::make("identity", None).unwrap();
let mut pad_names = identity
.get_pads()
.iter()
.map(|p| p.get_name())
.collect::<Vec<String>>();
pad_names.sort();
assert_eq!(pad_names, vec![String::from("sink"), String::from("src")]);
let mut pad_names = identity
.get_sink_pads()
.iter()
.map(|p| p.get_name())
.collect::<Vec<String>>();
pad_names.sort();
assert_eq!(pad_names, vec![String::from("sink")]);
let mut pad_names = identity
.get_src_pads()
.iter()
.map(|p| p.get_name())
.collect::<Vec<String>>();
pad_names.sort();
assert_eq!(pad_names, vec![String::from("src")]);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment