Adapt tests to new api

This commit is contained in:
Maarten Bosmans 2009-06-13 12:01:29 +02:00 committed by Sebastian Dröge
parent f100210c37
commit 14d7c20ce7
5 changed files with 33 additions and 37 deletions

View file

@ -29,17 +29,17 @@ public class BinTest
} }
[Test] [Test]
public void TestAddMany() public void TestAdd()
{ {
Bin bin = new Bin("test-bin"); Bin bin = new Bin("test-bin");
Element e1 = ElementFactory.Make("fakesrc", "fakesrc"); Element e1 = ElementFactory.Make("fakesrc", "fakesrc");
Element e2 = ElementFactory.Make("fakesink", "fakesink"); Element e2 = ElementFactory.Make("fakesink", "fakesink");
Assert.IsNotNull(bin, "Could not create bin"); Assert.IsNotNull(bin, "Could not create bin");
Assert.IsNotNull(e1, "Could not create fakesrc"); Assert.IsNotNull(e1, "Could not create fakesrc");
Assert.IsNotNull(e2, "Could not create fakesink"); Assert.IsNotNull(e2, "Could not create fakesink");
bin.AddMany(e1, e2); bin.Add(e1, e2);
Assert.AreEqual(bin.ChildrenCount, 2); Assert.AreEqual(bin.ChildrenCount, 2);
} }
@ -75,10 +75,9 @@ public class BinTest
} }
Assert.AreEqual(elements.Length, bin.ChildrenCount); Assert.AreEqual(elements.Length, bin.ChildrenCount);
Element [] children = bin.Children;
for(int i = 0; i < elements.Length; i++) { for(uint i = 0; i < elements.Length; i++) {
Assert.AreEqual(elements[elements.Length - i - 1], children[i]); Assert.AreEqual(elements[elements.Length - i - 1], bin.GetChildByIndex(i));
} }
} }

View file

@ -36,9 +36,9 @@ public class CapsTest
} }
[Test] [Test]
public void TestNewFromString() public void TestFromString()
{ {
Caps caps = Caps.NewFromString("video/x-raw-yuv, " + Caps caps = Caps.FromString("video/x-raw-yuv, " +
"format=(fourcc)I420, " + "format=(fourcc)I420, " +
"width=(int)384, " + "width=(int)384, " +
"height=(int)288, " + "height=(int)288, " +
@ -54,12 +54,12 @@ public class CapsTest
[Test] [Test]
public void TestIntersecting() public void TestIntersecting()
{ {
Caps caps1 = Caps.NewFromString("video/x-raw-yuv, " + Caps caps1 = Caps.FromString("video/x-raw-yuv, " +
"format=(fourcc)I420, " + "format=(fourcc)I420, " +
"width=(int)[ 1,1000 ], " + "width=(int)[ 1,1000 ], " +
"height=(int)[ 1, 1000 ], " + "height=(int)[ 1, 1000 ], " +
"framerate=(fraction)[ 0/1, 100/1 ]"); "framerate=(fraction)[ 0/1, 100/1 ]");
Caps caps2 = Caps.NewFromString("video/x-raw-yuv, " + Caps caps2 = Caps.FromString("video/x-raw-yuv, " +
"format=(fourcc)I420, " + "format=(fourcc)I420, " +
"width=(int)640, " + "width=(int)640, " +
"height=(int)480"); "height=(int)480");
@ -80,10 +80,10 @@ public class CapsTest
[Test] [Test]
public void TestUnion() public void TestUnion()
{ {
Caps caps1 = Caps.NewFromString("video/x-raw-yuv, " + Caps caps1 = Caps.FromString("video/x-raw-yuv, " +
"format=(fourcc)I420, " + "format=(fourcc)I420, " +
"width=(int)640"); "width=(int)640");
Caps caps2 = Caps.NewFromString("video/x-raw-yuv, " + Caps caps2 = Caps.FromString("video/x-raw-yuv, " +
"format=(fourcc)I420, " + "format=(fourcc)I420, " +
"height=(int)480"); "height=(int)480");
Assert.IsNotNull(caps1); Assert.IsNotNull(caps1);

View file

@ -25,12 +25,12 @@ public class MessageTest {
[Test] [Test]
public void TestParsing() public void TestParsing()
{ {
Message message = new Message(null); Message message = Message.NewEos(null);
Assert.IsNotNull(message); Assert.IsNotNull(message);
Assert.AreEqual(message.Type, MessageType.Eos); Assert.AreEqual(message.Type, MessageType.Eos);
Assert.IsNull(message.Src); Assert.IsNull(message.Src);
message = new Message(null, "error string"); message = Message.NewError(null, CoreError.TooLazy);
Assert.IsNotNull(message); Assert.IsNotNull(message);
Assert.AreEqual(message.Type, MessageType.Error); Assert.AreEqual(message.Type, MessageType.Error);
Assert.IsNull(message.Src); Assert.IsNull(message.Src);

View file

@ -46,14 +46,14 @@ public class PadTest
public static Caps PadGetCapsStub(Pad pad) public static Caps PadGetCapsStub(Pad pad)
{ {
return Caps.NewFromString("video/x-raw-yuv"); return Caps.FromString("video/x-raw-yuv");
} }
[Test] [Test]
public void TestFuncAssigning() public void TestFuncAssigning()
{ {
Pad src = new Pad("src", PadDirection.Src); Pad src = new Pad("src", PadDirection.Src);
src.GetcapsFunction = new PadGetCapsFunction(PadGetCapsStub); src.GetCapsFunction = new PadGetCapsFunction(PadGetCapsStub);
Caps caps = src.Caps; Caps caps = src.Caps;
@ -69,8 +69,8 @@ public class PadTest
Assert.IsNotNull(element); Assert.IsNotNull(element);
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle"); Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
Pad src = element.GetPad("src"); Pad src = element.GetStaticPad("src");
Pad sink = element.GetPad("sink"); Pad sink = element.GetStaticPad("sink");
Assert.IsNotNull(src, "Ooops, src pad is null"); Assert.IsNotNull(src, "Ooops, src pad is null");
Assert.IsNotNull(sink, "Ooops, sink pad is null"); Assert.IsNotNull(sink, "Ooops, sink pad is null");
@ -92,17 +92,13 @@ public class PadTest
Assert.IsNotNull(element); Assert.IsNotNull(element);
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle"); Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
Assert.AreEqual(2, element.Numpads);
Pad [] pads = new Pad [element.Numpads];
element.Pads.CopyTo (pads, 0);
bool hassink = false; bool hassink = false;
bool hassrc = false; bool hassrc = false;
for(int i = 0; i < element.Numpads; i++) { foreach(Pad pad in element.Pads) {
if (pads [i].Name == "src") if (pad.Name == "src")
hassrc = true; hassrc = true;
else if (pads [i].Name == "sink") else if (pad.Name == "sink")
hassink = true; hassink = true;
} }
@ -148,7 +144,7 @@ public class PadTest
Caps caps = src.AllowedCaps; Caps caps = src.AllowedCaps;
Assert.IsNull(caps); Assert.IsNull(caps);
caps = Caps.NewFromString("foo/bar"); caps = Caps.FromString("foo/bar");
src.SetCaps(caps); src.SetCaps(caps);
sink.SetCaps(caps); sink.SetCaps(caps);
@ -175,13 +171,13 @@ public class PadTest
Caps caps = src.AllowedCaps; Caps caps = src.AllowedCaps;
Assert.IsNull(caps); Assert.IsNull(caps);
caps = Caps.NewFromString("foo/bar"); caps = Caps.FromString("foo/bar");
src.SetCaps(caps); src.SetCaps(caps);
Gst.Buffer buffer = new Gst.Buffer(); Gst.Buffer buffer = new Gst.Buffer();
Assert.AreEqual(src.Push(buffer), FlowReturn.NotLinked); Assert.AreEqual(src.Push(buffer), FlowReturn.NotLinked);
ulong handler_id = src.AddBufferProbe(new Pad.BufferProbeDelegate(ProbeHandler)); ulong handler_id = src.AddBufferProbe(new PadBufferProbeCallback(ProbeHandler));
buffer = new Gst.Buffer(); buffer = new Gst.Buffer();
Assert.AreEqual(src.Push(buffer), FlowReturn.Ok); Assert.AreEqual(src.Push(buffer), FlowReturn.Ok);
} }

View file

@ -11,6 +11,7 @@ using System;
using NUnit.Framework; using NUnit.Framework;
using Gst; using Gst;
using Gst.CorePlugins;
[TestFixture] [TestFixture]
public class PipelineTest public class PipelineTest
@ -44,7 +45,7 @@ public class PipelineTest
Element sink = ElementFactory.Make("fakesink", null); Element sink = ElementFactory.Make("fakesink", null);
Bin bin = (Bin) pipeline; Bin bin = (Bin) pipeline;
bin.AddMany(src, sink); bin.Add(src, sink);
src.Link(sink); src.Link(sink);
Assert.AreEqual(((Element)pipeline).SetState(State.Ready), StateChangeReturn.Success); Assert.AreEqual(((Element)pipeline).SetState(State.Ready), StateChangeReturn.Success);
@ -61,7 +62,7 @@ public class PipelineTest
Element sink = ElementFactory.Make("fakesink", null); Element sink = ElementFactory.Make("fakesink", null);
Bin bin = (Bin) pipeline; Bin bin = (Bin) pipeline;
bin.AddMany(src, sink); bin.Add(src, sink);
src.Link(sink); src.Link(sink);
Bus bus = pipeline.Bus; Bus bus = pipeline.Bus;
@ -118,7 +119,7 @@ public class PipelineTest
Assert.IsNotNull(sink, "Could not create fakesink"); Assert.IsNotNull(sink, "Could not create fakesink");
Bin bin = (Bin) pipeline; Bin bin = (Bin) pipeline;
bin.AddMany(src, sink); bin.Add(src, sink);
Assert.IsTrue(src.Link(sink), "Could not link between src and sink"); Assert.IsTrue(src.Link(sink), "Could not link between src and sink");
Assert.AreEqual(pipeline.SetState(State.Playing), StateChangeReturn.Async); Assert.AreEqual(pipeline.SetState(State.Playing), StateChangeReturn.Async);
@ -135,17 +136,17 @@ public class PipelineTest
[Test] [Test]
public void TestBaseTime() { public void TestBaseTime() {
Element pipeline = ElementFactory.Make("pipeline", "pipeline"); Element pipeline = ElementFactory.Make("pipeline", "pipeline");
Element fakesrc = ElementFactory.Make("fakesrc", "fakesrc"); FakeSrc fakesrc = FakeSrc.Make("fakesrc");
Element fakesink = ElementFactory.Make("fakesink", "fakesink"); FakeSink fakesink = FakeSink.Make("fakesink");
Assert.IsNotNull(pipeline, "Could not create pipeline"); Assert.IsNotNull(pipeline, "Could not create pipeline");
Assert.IsNotNull(fakesrc, "Could not create fakesrc"); Assert.IsNotNull(fakesrc, "Could not create fakesrc");
Assert.IsNotNull(fakesink, "Could not create fakesink"); Assert.IsNotNull(fakesink, "Could not create fakesink");
fakesrc.SetProperty("is-live", true); fakesrc.IsLive = true;
Bin bin = (Bin) pipeline; Bin bin = (Bin) pipeline;
bin.AddMany(fakesrc, fakesink); bin.Add(fakesrc, fakesink);
Assert.IsTrue(fakesrc.Link(fakesink)); Assert.IsTrue(fakesrc.Link(fakesink));
Pad sink = fakesink.GetPad("sink"); Pad sink = fakesink.GetPad("sink");