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

This commit is contained in:
Sebastian Dröge 2017-10-26 13:29:37 +02:00
parent 50c8f32961
commit f08f0f6f15
2 changed files with 64 additions and 0 deletions

View file

@ -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")]
);
}
}

View file

@ -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")]);
}
}