From 8ad1c333e7077e14d5168f938227398474348faa Mon Sep 17 00:00:00 2001 From: Khaled Mohammed Date: Sat, 5 Aug 2006 21:07:11 +0000 Subject: [PATCH] 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 --- ChangeLog | 8 +++++ gstreamer-sharp/Gstreamer.metadata | 1 + gstreamer-sharp/Makefile.am | 3 +- tests/ElementTest.cs | 50 ++++++++++-------------------- tests/PipelineTest.cs | 21 +++++++++++++ 5 files changed, 49 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2cc7ed266..6b3f1d5773 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-08-05 Khaled Mohammed + * 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 * gstreamer-sharp/DynamicSignal.cs: Added the support for Retval. Also changed the design to use only managed code. diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata index 186ea4ea36..eda542fb2e 100644 --- a/gstreamer-sharp/Gstreamer.metadata +++ b/gstreamer-sharp/Gstreamer.metadata @@ -3,6 +3,7 @@ 1 1 + 1 1 diff --git a/gstreamer-sharp/Makefile.am b/gstreamer-sharp/Makefile.am index e5e8717db0..012ecd789a 100644 --- a/gstreamer-sharp/Makefile.am +++ b/gstreamer-sharp/Makefile.am @@ -56,7 +56,8 @@ customs = \ Debug.custom \ Element.custom \ Message.custom \ - Pad.custom + Pad.custom \ + Object.custom build_customs = $(addprefix $(srcdir)/, $(customs)) diff --git a/tests/ElementTest.cs b/tests/ElementTest.cs index 4ae39298b0..5b924544b8 100644 --- a/tests/ElementTest.cs +++ b/tests/ElementTest.cs @@ -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(); } } diff --git a/tests/PipelineTest.cs b/tests/PipelineTest.cs index ce9f5b6541..5f9534cdd1 100644 --- a/tests/PipelineTest.cs +++ b/tests/PipelineTest.cs @@ -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(); + } }