Methods

Class/Module Index [+]

Quicksearch

TC_xml

Constants

TEST_FILE

Public Instance Methods

test_xml() click to toggle source
# File gstreamer/tests/tc_xml.rb, line 24
def test_xml
    src = Gst::ElementFactory.make("fakesrc", "the_source")
    sink = Gst::ElementFactory.make("fakesink", "the_sink")
    assert_not_nil src
    assert_not_nil sink
    src >> sink
    pipe = Gst::Pipeline.new("the_pipeline")
    pipe.add(src, sink)

    assert Gst::XML.write_file(pipe, TEST_FILE), 
           "could not write pipeline in #{TEST_FILE}"

    assert_instance_of(Gst::XML, parser = Gst::XML.new)
    assert parser.parse_file(TEST_FILE)
    pipe = parser.get_element("the_pipeline")
    assert_instance_of(Gst::Pipeline, pipe)
    assert pipe.size == 2
    assert_instance_of(Gst::Element, pipe.get_by_name("the_source")) 
    assert_instance_of(Gst::Element, pipe.get_by_name("the_sink"))

    i = 0 
    check_proc = Proc.new do |x|
        assert_instance_of(Gst::Element, x)
        i += 1
        if x.is_a?(Gst::Bin)
            i += x.size
        end
    end
    parser.each_topelement { |x| check_proc.call(x) }
    assert_equal(3, i)
    i = 0 
    parser.topelements.each { |x| check_proc.call(x) }
    assert_equal(3, i)

    pipe.play
    100.times { assert pipe.iterate }
    pipe.stop
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.