mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-04 14:38:48 +00:00
Adjust tests for new protected methods by implementing subclasses
This commit is contained in:
parent
58c9aeb8a6
commit
bb977f37f6
2 changed files with 39 additions and 26 deletions
|
@ -119,26 +119,31 @@ public class BinTest
|
||||||
CollectionAssert.AreEquivalent(elements, bin.ElementsSorted);
|
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]
|
[Test]
|
||||||
public void TestGhostPad()
|
public void TestGhostPad()
|
||||||
{
|
{
|
||||||
Bin bin = new Bin();
|
new MyBin ();
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,25 @@ public class ElementTest
|
||||||
Assert.IsFalse(Element.Link(src, sink));
|
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]
|
[Test]
|
||||||
public void TestAddRemovePad()
|
public void TestAddRemovePad()
|
||||||
{
|
{
|
||||||
Element e = ElementFactory.Make("fakesrc", "source");
|
new PadAddElement ();
|
||||||
Pad pad = new Pad("source", PadDirection.Src);
|
|
||||||
|
|
||||||
e.AddPad(pad);
|
|
||||||
Assert.AreEqual(pad, e.GetStaticPad("source"));
|
|
||||||
|
|
||||||
e.RemovePad(pad);
|
|
||||||
Assert.IsNull(e.GetStaticPad("source"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
Loading…
Reference in a new issue