Fix of Refcount property in Gst.Object

git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@63396 e3ebcda4-bce8-0310-ba0a-eca2169e7518
This commit is contained in:
Khaled Mohammed 2006-08-05 21:07:11 +00:00
parent 01cf9177ac
commit 8ad1c333e7
5 changed files with 49 additions and 34 deletions

View file

@ -1,3 +1,11 @@
2006-08-05 Khaled Mohammed <khaled.mohammed@gmail.com>
* gstreamer-sharp/GStreamer.metadata: added a new xml node to hide
generation of Refcount by GAPI.
* gstreamer-sharp/Object.custom: added Refcount property there.
* tests/ElementTest.cs: Adding test to Add/Remove Pad.
2006-08-03 Khaled Mohammed <khaled.mohammed@gmail.com>
* gstreamer-sharp/DynamicSignal.cs: Added the support for Retval.
Also changed the design to use only managed code.

View file

@ -3,6 +3,7 @@
<attr path="/api/namespace/object[@name='Bin']" name="disable_gtype_ctor">1</attr>
<attr path="/api/namespace/object[@name='Pipeline']" name="disable_gtype_ctor">1</attr>
<attr path="/api/namespace/object[@name='Object']/field[@name='Refcount']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Bin']/field[@name='Children']" name="hidden">1</attr>

View file

@ -56,7 +56,8 @@ customs = \
Debug.custom \
Element.custom \
Message.custom \
Pad.custom
Pad.custom \
Object.custom
build_customs = $(addprefix $(srcdir)/, $(customs))

View file

@ -28,43 +28,27 @@ public class ElementTest
}
[Test]
public void TestGoodConstructor()
public void TestAddRemovePad()
{
Element sink = ElementFactory.Make("fakesink", "fake-sink");
Assert.IsNotNull(sink, "fakesink plugin is not installed?");
Assert.IsFalse(sink.Handle == IntPtr.Zero, "sink Element has null handle");
//Assert.IsInstanceOfType(typeof(Element), sink, "sink is not an Element?");
Assert.AreEqual(sink.Name, "fake-sink");
sink.Dispose();
}
[Test]
public void TestAddingAndRemovingPads()
{
Element src = ElementFactory.Make("fakesrc", "fake-src");
Assert.IsNotNull(src, "fakesrc plugin is not installed?");
Element e = ElementFactory.Make("fakesrc", "source");
/* create a new floating pad with refcount 1 */
Pad p = new Pad("source", PadDirection.Src);
Assert.AreEqual(p.Refcount, 1, "pad");
Pad [] pads = new Pad[2];
/* ref it for ourselves */
Gst.Object.Ref(p.Handle);
Assert.AreEqual(p.Refcount, 2, "pad");
/* adding it sinks the pad -> not floating, same refcount */
e.AddPad(p);
Assert.AreEqual(p.Refcount, 2, "pad");
pads[0] = new Pad("src1", PadDirection.Src);
pads[1] = new Pad("src2", PadDirection.Sink);
foreach(Pad P in pads) {
src.AddPad(P);
}
foreach(Pad P in pads) {
//Assert.IsTrue(src.Pads.IndexOf(P) >= 0);
}
foreach(Pad P in pads) {
Assert.IsTrue(src.RemovePad(P));
}
/* removing it reduces the refcount */
e.RemovePad(p);
Assert.AreEqual(p.Refcount, 1, "pad");
/* clean up our own reference */
p.Dispose();
e.Dispose();
}
}

View file

@ -170,4 +170,25 @@ public class PipelineTest
pipeline.Dispose();
bus.Dispose();
}
[Test]
public void TestBaseTime() {
Element pipeline = ElementFactory.Make("pipeline", "pipeline");
Element fakesrc = ElementFactory.Make("fakesrc", "fakesrc");
Element fakesink = ElementFactory.Make("fakesink", "fakesink");
Assert.IsNotNull(pipeline, "Could not create pipeline");
Assert.IsNotNull(fakesrc, "Could not create fakesrc");
Assert.IsNotNull(fakesink, "Could not create fakesink");
fakesrc.SetProperty("is-live", true);
Bin bin = (Bin) pipeline;
bin.AddMany(fakesrc, fakesink);
Assert.IsTrue(fakesrc.Link(fakesink));
Pad sink = fakesink.GetPad("sink");
pipeline.Dispose();
}
}