if (media == null) {
return; // don't continue if not supported
}
// Add some source elements.
SourceElement source0 = media.addSource("file.ogg", "audio/ogg");
SourceElement source1 = media.addSource("file.ogv", "video/ogg");
SourceElement source2 = media.addSource("file.mp3");
assertEquals(media.getElement(), source0.getParentElement());
assertEquals(media.getElement(), source1.getParentElement());
assertEquals(media.getElement(), source2.getParentElement());
// Remove a source.
media.removeSource(source1);
assertEquals(media.getElement(), source0.getParentElement());
assertNull(source1.getParentElement());
assertEquals(media.getElement(), source2.getParentElement());
// Let a source remove itself.
source2.removeFromParent();
assertEquals(media.getElement(), source0.getParentElement());
assertNull(source1.getParentElement());
assertNull(source2.getParentElement());
// Remove a source that is not a child.
media.removeSource(source0);
}