diff --git a/tests/BinTest.cs b/tests/BinTest.cs index 79d859e1b7..f64ac30d2f 100644 --- a/tests/BinTest.cs +++ b/tests/BinTest.cs @@ -119,26 +119,31 @@ public class BinTest CollectionAssert.AreEquivalent(elements, bin.ElementsSorted); } + public class MyBin : Gst.Bin { + public MyBin () : base () { + Element filesrc = ElementFactory.Make("filesrc"); + Add(filesrc); + CollectionAssert.IsEmpty(Pads); + + GhostPad pad1 = new GhostPad("ghost-sink", PadDirection.Sink); + GhostPad pad2 = new GhostPad("ghost-src", new PadTemplate("src-template", PadDirection.Src, PadPresence.Request, Caps.NewAny())); + + Assert.IsFalse(pad1.SetTarget(filesrc.GetStaticPad("src"))); + Assert.IsTrue(pad2.SetTarget(filesrc.GetStaticPad("src"))); + + AddPad(pad1); + AddPad(pad2); + + CollectionAssert.Contains(Pads, pad1); + CollectionAssert.Contains(Pads, pad2); + CollectionAssert.Contains(SinkPads, pad1); + CollectionAssert.Contains(SrcPads, pad2); + } + } + [Test] public void TestGhostPad() { - Bin bin = new Bin(); - Element filesrc = ElementFactory.Make("filesrc"); - bin.Add(filesrc); - CollectionAssert.IsEmpty(bin.Pads); - - GhostPad pad1 = new GhostPad("ghost-sink", PadDirection.Sink); - GhostPad pad2 = new GhostPad("ghost-src", new PadTemplate("src-template", PadDirection.Src, PadPresence.Request, Caps.NewAny())); - - Assert.IsFalse(pad1.SetTarget(filesrc.GetStaticPad("src"))); - Assert.IsTrue(pad2.SetTarget(filesrc.GetStaticPad("src"))); - - bin.AddPad(pad1); - bin.AddPad(pad2); - - CollectionAssert.Contains(bin.Pads, pad1); - CollectionAssert.Contains(bin.Pads, pad2); - CollectionAssert.Contains(bin.SinkPads, pad1); - CollectionAssert.Contains(bin.SrcPads, pad2); + new MyBin (); } } diff --git a/tests/ElementTest.cs b/tests/ElementTest.cs index 2fe57be7b8..d15ec5ddc9 100644 --- a/tests/ElementTest.cs +++ b/tests/ElementTest.cs @@ -31,17 +31,25 @@ public class ElementTest Assert.IsFalse(Element.Link(src, sink)); } + public class PadAddElement : Gst.Element { + public PadAddElement () : base () { + Pad pad = new Pad("source", PadDirection.Src); + CollectionAssert.IsEmpty(Pads); + + AddPad(pad); + Assert.AreEqual(pad, GetStaticPad("source")); + CollectionAssert.Contains(Pads, pad); + + RemovePad(pad); + Assert.IsNull(GetStaticPad("source")); + CollectionAssert.IsEmpty(Pads); + } + } + [Test] public void TestAddRemovePad() { - Element e = ElementFactory.Make("fakesrc", "source"); - Pad pad = new Pad("source", PadDirection.Src); - - e.AddPad(pad); - Assert.AreEqual(pad, e.GetStaticPad("source")); - - e.RemovePad(pad); - Assert.IsNull(e.GetStaticPad("source")); + new PadAddElement (); } [Test]