Adjust tests for new protected methods by implementing subclasses

This commit is contained in:
Sebastian Dröge 2009-06-23 13:26:11 +02:00
parent 58c9aeb8a6
commit bb977f37f6
2 changed files with 39 additions and 26 deletions

View file

@ -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 ();
}
}

View file

@ -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]