Add some tests that where lost in Refcount cleanup

This commit is contained in:
Maarten Bosmans 2009-06-18 18:07:53 +02:00 committed by Sebastian Dröge
parent 89ffc66700
commit 1bf7205563
4 changed files with 104 additions and 16 deletions

View file

@ -38,6 +38,32 @@ public class BinTest
Assert.AreEqual(bin.ChildrenCount, 2); Assert.AreEqual(bin.ChildrenCount, 2);
} }
[Test]
public void TestAddRemove()
{
Bin bin = ElementFactory.Make("bin") as Bin;
Assert.IsNotNull(bin, "Could not create bin");
Element e1 = new FakeSrc("fakesrc");
Element e2 = new Identity("identity");
Element e3 = new FakeSink("fakesink");
Assert.IsNotNull(e1, "Could not create fakesrc");
Assert.IsNotNull(e2, "Could not create identity");
Assert.IsNotNull(e3, "Could not create fakesink");
bin.Add(e1, e2, e3);
Element.Link(e1, e2, e3);
Assert.AreEqual(bin.ChildrenCount, 3);
bin.Remove(e2, e3);
Assert.AreEqual(bin.ChildrenCount, 1);
bin.Add(e2);
Assert.AreEqual(bin.ChildrenCount, 2);
bin.Remove(e1, e2);
Assert.AreEqual(bin.ChildrenCount, 0);
}
[Test] [Test]
public void TestGetByName() public void TestGetByName()
{ {
@ -52,15 +78,15 @@ public class BinTest
} }
[Test] [Test]
public void TestChildren() public void TestGetChildByIndex()
{ {
Bin bin = new Bin("test-bin"); Bin bin = new Bin("test-bin");
Element [] elements = new Element [] { Element [] elements = new Element [] {
ElementFactory.Make("fakesrc", "fakesrc"), ElementFactory.Make("fakesrc", "fakesrc"),
ElementFactory.Make("audioconvert", "audioconvert"), ElementFactory.Make("audioconvert", "audioconvert"),
ElementFactory.Make("wavenc", "wavenc"), ElementFactory.Make("wavenc", "wavenc"),
ElementFactory.Make("fakesink", "fakesink") ElementFactory.Make("fakesink", "fakesink")
}; };
foreach(Element element in elements) { foreach(Element element in elements) {
@ -73,16 +99,4 @@ public class BinTest
Assert.AreEqual(elements[elements.Length - i - 1], bin.GetChildByIndex(i)); Assert.AreEqual(elements[elements.Length - i - 1], bin.GetChildByIndex(i));
} }
} }
[Test]
public void TestInterface()
{
Bin bin = new Bin(String.Empty);
Assert.IsNotNull(bin, "Could not create bin");
Element filesrc = ElementFactory.Make("filesrc");
Assert.IsNotNull(filesrc, "Could not create filesrc");
bin.Add(filesrc);
}
} }

View file

@ -18,6 +18,25 @@ public class BufferTest
Application.Init(); Application.Init();
} }
[Test]
public void TestCaps()
{
Gst.Buffer buffer = new Gst.Buffer(4);
Caps caps = Caps.FromString("audio/x-raw-int");
Assert.IsNull(buffer.Caps, "buffer.Caps should be null");
buffer.Caps = caps;
Assert.IsNotNull(buffer.Caps, "buffer.Caps is null");
Caps caps2 = Caps.FromString("audio/x-raw-float");
buffer.Caps = caps2;
Assert.AreNotEqual(buffer.Caps, caps);
Assert.AreEqual(buffer.Caps, caps2);
buffer.Caps = null;
Assert.IsNull(buffer.Caps, "buffer.Caps should be null");
}
[Test] [Test]
public void TestSubbuffer() public void TestSubbuffer()
{ {

View file

@ -27,5 +27,51 @@ public class ElementTest
Element sink = new Bin("sink"); Element sink = new Bin("sink");
Assert.IsFalse(src.Link(sink)); Assert.IsFalse(src.Link(sink));
Assert.IsFalse(Element.Link(src, sink));
}
[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"));
}
[Test]
public void TestLink()
{
State state, pending;
Element source = ElementFactory.Make("fakesrc", "source");
Assert.IsNotNull(source);
Element sink = ElementFactory.Make("fakesink", "sink");
Assert.IsNotNull(sink);
Assert.IsTrue(source.LinkPads("src", sink, "sink"));
sink.SetState(State.Paused);
source.SetState(State.Paused);
sink.GetState(out state, out pending, Clock.TimeNone);
Assert.AreEqual(state, State.Paused);
sink.SetState(State.Playing);
source.SetState(State.Playing);
source.GetState(out state, out pending, Clock.TimeNone);
Assert.AreEqual(state, State.Playing);
sink.SetState(State.Null);
source.SetState(State.Null);
sink.GetState(out state, out pending, Clock.TimeNone);
Assert.AreEqual(state, State.Null);
Assert.AreEqual(source.GetStaticPad("src").Peer, sink.GetStaticPad("sink"));
source.Unlink(sink);
Assert.IsFalse(source.GetStaticPad("src").IsLinked);
} }
} }

View file

@ -21,6 +21,15 @@ public class PipelineTest
Application.Init(); Application.Init();
} }
[Test]
public void TestPipeline()
{
Pipeline pipeline = new Pipeline(String.Empty);
Assert.IsNotNull(pipeline, "Could not create pipeline");
Assert.IsNotNull(pipeline.Bus, "Bus on pipeline is null");
Assert.IsNotNull(pipeline.Clock, "Clock on pipeline is null");
}
[Test] [Test]
public void TestAsyncStateChangeEmpty() public void TestAsyncStateChangeEmpty()
{ {