Some more cleanup

This commit is contained in:
Maarten Bosmans 2009-06-15 10:01:40 +02:00 committed by Sebastian Dröge
parent 8e9831765a
commit 93bee322fb
5 changed files with 43 additions and 40 deletions

View file

@ -11,6 +11,7 @@
using System;
using NUnit.Framework;
using Gst;
using Gst.CorePlugins;
[TestFixture]
public class BinTest
@ -25,8 +26,8 @@ public class BinTest
public void TestAdd()
{
Bin bin = new Bin("test-bin");
Element e1 = ElementFactory.Make("fakesrc", "fakesrc");
Element e2 = ElementFactory.Make("fakesink", "fakesink");
Element e1 = new FakeSrc("fakesrc");
Element e2 = new FakeSink("fakesink");
Assert.IsNotNull(bin, "Could not create bin");
Assert.IsNotNull(e1, "Could not create fakesrc");
@ -79,7 +80,7 @@ public class BinTest
Bin bin = new Bin(String.Empty);
Assert.IsNotNull(bin, "Could not create bin");
Element filesrc = ElementFactory.Make("filesrc", null);
Element filesrc = ElementFactory.Make("filesrc");
Assert.IsNotNull(filesrc, "Could not create filesrc");
bin.Add(filesrc);

View file

@ -89,12 +89,12 @@ public class CapsTest
Assert.IsFalse(caps3.IsEmpty, "How come caps are EMPTY?!");
Assert.AreEqual("video/x-raw-yuv, " +
Caps caps4 = Caps.FromString("video/x-raw-yuv, " +
"format=(fourcc)I420, " +
"width=(int)640; " +
"video/x-raw-yuv, " +
"format=(fourcc)I420, " +
"height=(int)480",
caps3.ToString());
"height=(int)480");
Assert.IsTrue(caps3.IsEqual(caps4));
}
}

View file

@ -20,12 +20,6 @@ public class ElementTest
Application.Init();
}
[Test]
public void TestErrorNoBus()
{
Element e = ElementFactory.Make("fakesrc", "source");
}
[Test]
public void TestLinkNoPads()
{

View file

@ -59,7 +59,7 @@ public class PadTest
[Test]
public void TestElementPadAccessByName()
{
Element element = ElementFactory.Make("identity", null);
Element element = ElementFactory.Make("identity");
Assert.IsNotNull(element);
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
@ -82,7 +82,7 @@ public class PadTest
[Test]
public void TestElementPadAccessByList()
{
Element element = ElementFactory.Make("identity", null);
Element element = ElementFactory.Make("identity");
Assert.IsNotNull(element);
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
@ -118,24 +118,14 @@ public class PadTest
[Test]
public void TestGetAllowedCaps()
{
/*
Gst.Buffer buffer = new Gst.Buffer();
Caps caps;
try {
Pad pbuffer = (Pad) buffer;
Caps pcaps = pbuffer.AllowedCaps;
}
catch (Exception ex) {
Assert.Fail("buffer.AllowedCaps failed");
}
*/
Pad sink = new Pad("sink", PadDirection.Sink);
// try { Caps tcaps = sink.AllowedCaps; }
// catch (Exception) { Assert.Fail("sink.AllowedCaps failed"); }
caps = sink.AllowedCaps;
Assert.IsNull(caps);
Pad src = new Pad("src", PadDirection.Src);
Assert.IsNotNull(src);
Caps caps = src.AllowedCaps;
caps = src.AllowedCaps;
Assert.IsNull(caps);
caps = Caps.FromString("foo/bar");
@ -153,7 +143,7 @@ public class PadTest
bool ProbeHandler(Pad pad, Gst.Buffer buffer)
{
//Assert.Fail("event worked");
//Console.WriteLine("event worked");
return false;
}
@ -172,7 +162,8 @@ public class PadTest
Assert.AreEqual(src.Push(buffer), FlowReturn.NotLinked);
ulong handler_id = src.AddBufferProbe(new PadBufferProbeCallback(ProbeHandler));
buffer = new Gst.Buffer();
Assert.AreEqual(src.Push(buffer), FlowReturn.Ok);
buffer = new Gst.Buffer(new byte[] {0});
FlowReturn flowreturn = src.Push(buffer);
Assert.AreEqual(flowreturn, FlowReturn.Ok);
}
}

View file

@ -34,8 +34,8 @@ public class PipelineTest
public void TestAsyncStateChangeFakeReady()
{
Pipeline pipeline = new Pipeline(String.Empty);
Element src = ElementFactory.Make("fakesrc", null);
Element sink = ElementFactory.Make("fakesink", null);
Element src = ElementFactory.Make("fakesrc");
Element sink = ElementFactory.Make("fakesink");
Bin bin = (Bin) pipeline;
bin.Add(src, sink);
@ -51,8 +51,8 @@ public class PipelineTest
Pipeline pipeline = new Pipeline(String.Empty);
Assert.IsNotNull(pipeline, "Could not create pipeline");
Element src = ElementFactory.Make("fakesrc", null);
Element sink = ElementFactory.Make("fakesink", null);
Element src = ElementFactory.Make("fakesrc");
Element sink = ElementFactory.Make("fakesink");
Bin bin = (Bin) pipeline;
bin.Add(src, sink);
@ -67,7 +67,6 @@ public class PipelineTest
Message message = bus.Poll(MessageType.StateChanged, -1);
if(message != null) {
message.ParseStateChanged(out old, out newState, out pending);
//Console.WriteLine("state change from {0} to {1}", old, newState);
if(message.Src == (Gst.Object) pipeline && newState == State.Playing)
done = true;
}
@ -99,22 +98,40 @@ public class PipelineTest
}
return true;
}
[Test]
[Ignore("This test does not terminate")]
public void TestBus()
[Ignore("This test causes a crash")]
public void TestBusAddWatch()
{
TestBusCallback(true);
}
[Test]
public void TestBusAddSignalWatch()
{
TestBusCallback(false);
}
public void TestBusCallback(bool use_AddWatch)
{
pipeline = new Pipeline(String.Empty);
Assert.IsNotNull(pipeline, "Could not create pipeline");
Element src = ElementFactory.Make("fakesrc", null);
Element src = ElementFactory.Make("fakesrc");
Assert.IsNotNull(src, "Could not create fakesrc");
Element sink = ElementFactory.Make("fakesink", null);
Element sink = ElementFactory.Make("fakesink");
Assert.IsNotNull(sink, "Could not create fakesink");
Bin bin = (Bin) pipeline;
bin.Add(src, sink);
Assert.IsTrue(src.Link(sink), "Could not link between src and sink");
if (use_AddWatch)
pipeline.Bus.AddWatch(new BusFunc(MessageReceived));
else {
pipeline.Bus.AddSignalWatch();
pipeline.Bus.Message += delegate (object o, MessageArgs args) {MessageReceived(null, args.Message);};
}
Assert.AreEqual(pipeline.SetState(State.Playing), StateChangeReturn.Async);
loop = new GLib.MainLoop();