mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
Fix source code formatting for all the tests
This commit is contained in:
parent
37b8bdd10d
commit
8e9831765a
8 changed files with 338 additions and 349 deletions
|
@ -13,24 +13,23 @@ using NUnit.Framework;
|
|||
[TestFixture]
|
||||
public class ApplicationTest
|
||||
{
|
||||
[Test]
|
||||
public void Init()
|
||||
{
|
||||
Gst.Application.Init();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitArgs()
|
||||
{
|
||||
string [] args = { "arg_a", "arg_b" };
|
||||
Gst.Application.Init("gstreamer-sharp-test", ref args);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitArgsCheck()
|
||||
{
|
||||
string [] args = { "arg_a", "arg_b" };
|
||||
Gst.Application.InitCheck("gstreamer-sharp-test", ref args);
|
||||
}
|
||||
}
|
||||
[Test]
|
||||
public void Init()
|
||||
{
|
||||
Gst.Application.Init();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitArgs()
|
||||
{
|
||||
string [] args = { "arg_a", "arg_b" };
|
||||
Gst.Application.Init("gstreamer-sharp-test", ref args);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InitArgsCheck()
|
||||
{
|
||||
string [] args = { "arg_a", "arg_b" };
|
||||
Gst.Application.InitCheck("gstreamer-sharp-test", ref args);
|
||||
}
|
||||
}
|
||||
|
|
108
tests/BinTest.cs
108
tests/BinTest.cs
|
@ -10,70 +10,68 @@
|
|||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
using Gst;
|
||||
|
||||
[TestFixture]
|
||||
public class BinTest
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAdd()
|
||||
{
|
||||
Bin bin = new Bin("test-bin");
|
||||
Element e1 = ElementFactory.Make("fakesrc", "fakesrc");
|
||||
Element e2 = ElementFactory.Make("fakesink", "fakesink");
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
|
||||
Assert.IsNotNull(bin, "Could not create bin");
|
||||
Assert.IsNotNull(e1, "Could not create fakesrc");
|
||||
Assert.IsNotNull(e2, "Could not create fakesink");
|
||||
[Test]
|
||||
public void TestAdd()
|
||||
{
|
||||
Bin bin = new Bin("test-bin");
|
||||
Element e1 = ElementFactory.Make("fakesrc", "fakesrc");
|
||||
Element e2 = ElementFactory.Make("fakesink", "fakesink");
|
||||
|
||||
bin.Add(e1, e2);
|
||||
|
||||
Assert.AreEqual(bin.ChildrenCount, 2);
|
||||
}
|
||||
Assert.IsNotNull(bin, "Could not create bin");
|
||||
Assert.IsNotNull(e1, "Could not create fakesrc");
|
||||
Assert.IsNotNull(e2, "Could not create fakesink");
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestGetByName()
|
||||
{
|
||||
Bin bin = new Bin("test-bin");
|
||||
Element e1 = ElementFactory.Make("fakesrc", "element-name");
|
||||
bin.Add(e1);
|
||||
|
||||
e1 = bin.GetByName("element-name");
|
||||
|
||||
Assert.IsNotNull(e1);
|
||||
Assert.AreEqual(e1.Name, "element-name");
|
||||
}
|
||||
bin.Add(e1, e2);
|
||||
|
||||
[Test]
|
||||
public void TestChildren()
|
||||
{
|
||||
Bin bin = new Bin("test-bin");
|
||||
Assert.AreEqual(bin.ChildrenCount, 2);
|
||||
}
|
||||
|
||||
Element [] elements = new Element [] {
|
||||
ElementFactory.Make("fakesrc", "fakesrc"),
|
||||
ElementFactory.Make("audioconvert", "audioconvert"),
|
||||
ElementFactory.Make("wavenc", "wavenc"),
|
||||
ElementFactory.Make("fakesink", "fakesink")
|
||||
};
|
||||
|
||||
foreach(Element element in elements) {
|
||||
bin.Add(element);
|
||||
}
|
||||
|
||||
Assert.AreEqual(elements.Length, bin.ChildrenCount);
|
||||
|
||||
for(uint i = 0; i < elements.Length; i++) {
|
||||
Assert.AreEqual(elements[elements.Length - i - 1], bin.GetChildByIndex(i));
|
||||
}
|
||||
}
|
||||
[Test]
|
||||
public void TestGetByName()
|
||||
{
|
||||
Bin bin = new Bin("test-bin");
|
||||
Element e1 = ElementFactory.Make("fakesrc", "element-name");
|
||||
bin.Add(e1);
|
||||
|
||||
e1 = bin.GetByName("element-name");
|
||||
|
||||
Assert.IsNotNull(e1);
|
||||
Assert.AreEqual(e1.Name, "element-name");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestChildren()
|
||||
{
|
||||
Bin bin = new Bin("test-bin");
|
||||
|
||||
Element [] elements = new Element [] {
|
||||
ElementFactory.Make("fakesrc", "fakesrc"),
|
||||
ElementFactory.Make("audioconvert", "audioconvert"),
|
||||
ElementFactory.Make("wavenc", "wavenc"),
|
||||
ElementFactory.Make("fakesink", "fakesink")
|
||||
};
|
||||
|
||||
foreach(Element element in elements) {
|
||||
bin.Add(element);
|
||||
}
|
||||
|
||||
Assert.AreEqual(elements.Length, bin.ChildrenCount);
|
||||
|
||||
for(uint i = 0; i < elements.Length; i++) {
|
||||
Assert.AreEqual(elements[elements.Length - i - 1], bin.GetChildByIndex(i));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestInterface()
|
||||
|
@ -86,6 +84,4 @@ public class BinTest
|
|||
|
||||
bin.Add(filesrc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ using NUnit.Framework;
|
|||
using Gst;
|
||||
|
||||
[TestFixture]
|
||||
public class BufferTest {
|
||||
public class BufferTest
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
|
@ -36,11 +37,9 @@ public class BufferTest {
|
|||
|
||||
Gst.Buffer sub2 = buffer.CreateSub(2, 2);
|
||||
Assert.IsNotNull(sub2, "CreateSub of buffer returned null");
|
||||
|
||||
|
||||
Assert.IsFalse(buffer.IsSpanFast(sub2), "a parent buffer can not be SpanFasted");
|
||||
Assert.IsFalse(sub1.IsSpanFast(buffer), "a parent buffer can not be SpanFasted");
|
||||
Assert.IsTrue(sub1.IsSpanFast(sub2), "two subbuffers next to each other should be SpanFast");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -9,93 +9,92 @@
|
|||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
using Gst;
|
||||
|
||||
[TestFixture]
|
||||
public class CapsTest
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPlainCreation()
|
||||
{
|
||||
Caps caps = new Caps();
|
||||
Assert.IsNotNull(caps);
|
||||
Assert.IsFalse(caps.Handle == IntPtr.Zero, "Ooops, null handle");
|
||||
}
|
||||
[Test]
|
||||
public void TestPlainCreation()
|
||||
{
|
||||
Caps caps = new Caps();
|
||||
Assert.IsNotNull(caps);
|
||||
Assert.IsFalse(caps.Handle == IntPtr.Zero, "Ooops, null handle");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFromString()
|
||||
{
|
||||
Caps caps = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)384, " +
|
||||
"height=(int)288, " +
|
||||
"framerate=(fraction)25/1");
|
||||
Assert.IsNotNull(caps);
|
||||
[Test]
|
||||
public void TestFromString()
|
||||
{
|
||||
Caps caps = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)384, " +
|
||||
"height=(int)288, " +
|
||||
"framerate=(fraction)25/1");
|
||||
Assert.IsNotNull(caps);
|
||||
|
||||
Assert.IsFalse(caps.Handle == IntPtr.Zero, "Ooops, null handle");
|
||||
Assert.IsTrue(caps.IsFixed, "Caps should be FIXED!");
|
||||
Assert.IsFalse(caps.IsEmpty, "Caps shouldn't be EMPTY!");
|
||||
Assert.IsFalse(caps.IsAny, "Caps shouldn't be ANY!");
|
||||
}
|
||||
Assert.IsFalse(caps.Handle == IntPtr.Zero, "Ooops, null handle");
|
||||
Assert.IsTrue(caps.IsFixed, "Caps should be FIXED!");
|
||||
Assert.IsFalse(caps.IsEmpty, "Caps shouldn't be EMPTY!");
|
||||
Assert.IsFalse(caps.IsAny, "Caps shouldn't be ANY!");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIntersecting()
|
||||
{
|
||||
Caps caps1 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)[ 1,1000 ], " +
|
||||
"height=(int)[ 1, 1000 ], " +
|
||||
"framerate=(fraction)[ 0/1, 100/1 ]");
|
||||
Caps caps2 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)640, " +
|
||||
"height=(int)480");
|
||||
Assert.IsNotNull(caps1);
|
||||
Assert.IsNotNull(caps2);
|
||||
[Test]
|
||||
public void TestIntersecting()
|
||||
{
|
||||
Caps caps1 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)[ 1,1000 ], " +
|
||||
"height=(int)[ 1, 1000 ], " +
|
||||
"framerate=(fraction)[ 0/1, 100/1 ]");
|
||||
Caps caps2 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)640, " +
|
||||
"height=(int)480");
|
||||
Assert.IsNotNull(caps1);
|
||||
Assert.IsNotNull(caps2);
|
||||
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps1");
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps2");
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps1");
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps2");
|
||||
|
||||
Caps caps3 = caps1.Intersect(caps2);
|
||||
Caps caps3 = caps1.Intersect(caps2);
|
||||
|
||||
Assert.IsFalse(caps3.IsFixed, "How come caps are FIXED?!");
|
||||
Assert.IsFalse(caps3.IsEmpty, "How come caps are EMPTY?!");
|
||||
Assert.IsFalse(caps3.IsFixed, "How come caps are FIXED?!");
|
||||
Assert.IsFalse(caps3.IsEmpty, "How come caps are EMPTY?!");
|
||||
|
||||
Assert.AreEqual(caps2.ToString() + ", framerate=(fraction)[ 0/1, 100/1 ]", caps3.ToString());
|
||||
}
|
||||
Assert.AreEqual(caps2.ToString() + ", framerate=(fraction)[ 0/1, 100/1 ]", caps3.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestUnion()
|
||||
{
|
||||
Caps caps1 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)640");
|
||||
Caps caps2 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"height=(int)480");
|
||||
Assert.IsNotNull(caps1);
|
||||
Assert.IsNotNull(caps2);
|
||||
[Test]
|
||||
public void TestUnion()
|
||||
{
|
||||
Caps caps1 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)640");
|
||||
Caps caps2 = Caps.FromString("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"height=(int)480");
|
||||
Assert.IsNotNull(caps1);
|
||||
Assert.IsNotNull(caps2);
|
||||
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps1");
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps2");
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps1");
|
||||
Assert.IsFalse(caps1.Handle == IntPtr.Zero, "Ooops, null handle in caps2");
|
||||
|
||||
Caps caps3 = caps1.Union(caps2);
|
||||
Caps caps3 = caps1.Union(caps2);
|
||||
|
||||
Assert.IsFalse(caps3.IsEmpty, "How come caps are EMPTY?!");
|
||||
Assert.IsFalse(caps3.IsEmpty, "How come caps are EMPTY?!");
|
||||
|
||||
Assert.AreEqual("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)640; " +
|
||||
"video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"height=(int)480",
|
||||
caps3.ToString());
|
||||
}
|
||||
Assert.AreEqual("video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"width=(int)640; " +
|
||||
"video/x-raw-yuv, " +
|
||||
"format=(fourcc)I420, " +
|
||||
"height=(int)480",
|
||||
caps3.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
using Gst;
|
||||
|
||||
[TestFixture]
|
||||
|
@ -36,4 +35,3 @@ public class ElementTest
|
|||
Assert.IsFalse(src.Link(sink));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
// (C) 2006
|
||||
//
|
||||
|
||||
using Gst;
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Gst;
|
||||
|
||||
public class MessageTest {
|
||||
public class MessageTest
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
|
@ -30,4 +31,3 @@ public class MessageTest {
|
|||
Assert.IsNull(message.Src);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
165
tests/PadTest.cs
165
tests/PadTest.cs
|
@ -10,96 +10,95 @@
|
|||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
using Gst;
|
||||
|
||||
[TestFixture]
|
||||
public class PadTest
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPlainCreation()
|
||||
{
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
Pad sink = new Pad("sink", PadDirection.Sink);
|
||||
|
||||
Assert.IsNotNull(src);
|
||||
Assert.IsNotNull(sink);
|
||||
[Test]
|
||||
public void TestPlainCreation()
|
||||
{
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
Pad sink = new Pad("sink", PadDirection.Sink);
|
||||
|
||||
Assert.IsFalse(src.Handle == IntPtr.Zero, "Ooops, src pad has null handle");
|
||||
Assert.IsFalse(sink.Handle == IntPtr.Zero, "Ooops, sink pad has null handle");
|
||||
Assert.IsNotNull(src);
|
||||
Assert.IsNotNull(sink);
|
||||
|
||||
Assert.AreEqual(PadDirection.Src, src.Direction);
|
||||
Assert.AreEqual(PadDirection.Sink, sink.Direction);
|
||||
}
|
||||
Assert.IsFalse(src.Handle == IntPtr.Zero, "Ooops, src pad has null handle");
|
||||
Assert.IsFalse(sink.Handle == IntPtr.Zero, "Ooops, sink pad has null handle");
|
||||
|
||||
public static Caps PadGetCapsStub(Pad pad)
|
||||
{
|
||||
return Caps.FromString("video/x-raw-yuv");
|
||||
}
|
||||
Assert.AreEqual(PadDirection.Src, src.Direction);
|
||||
Assert.AreEqual(PadDirection.Sink, sink.Direction);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("This test causes a crash")]
|
||||
public void TestFuncAssigning()
|
||||
{
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
src.GetCapsFunction = new PadGetCapsFunction(PadGetCapsStub);
|
||||
public static Caps PadGetCapsStub(Pad pad)
|
||||
{
|
||||
return Caps.FromString("video/x-raw-yuv");
|
||||
}
|
||||
|
||||
Caps caps = src.Caps;
|
||||
[Test]
|
||||
[Ignore("This test causes a crash")]
|
||||
public void TestFuncAssigning()
|
||||
{
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
src.GetCapsFunction = new PadGetCapsFunction(PadGetCapsStub);
|
||||
|
||||
Assert.IsNotNull(caps, "Ooops, returned caps is null");
|
||||
Assert.IsFalse(caps.IsEmpty == true, "Ooops, returned caps are empty");
|
||||
Assert.AreEqual("video/x-raw-yuv", caps.ToString ());
|
||||
}
|
||||
Caps caps = src.Caps;
|
||||
|
||||
[Test]
|
||||
public void TestElementPadAccessByName()
|
||||
{
|
||||
Element element = ElementFactory.Make("identity", null);
|
||||
Assert.IsNotNull(element);
|
||||
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
|
||||
Assert.IsNotNull(caps, "Ooops, returned caps is null");
|
||||
Assert.IsFalse(caps.IsEmpty == true, "Ooops, returned caps are empty");
|
||||
Assert.AreEqual("video/x-raw-yuv", caps.ToString ());
|
||||
}
|
||||
|
||||
Pad src = element.GetStaticPad("src");
|
||||
Pad sink = element.GetStaticPad("sink");
|
||||
[Test]
|
||||
public void TestElementPadAccessByName()
|
||||
{
|
||||
Element element = ElementFactory.Make("identity", null);
|
||||
Assert.IsNotNull(element);
|
||||
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
|
||||
|
||||
Assert.IsNotNull(src, "Ooops, src pad is null");
|
||||
Assert.IsNotNull(sink, "Ooops, sink pad is null");
|
||||
Pad src = element.GetStaticPad("src");
|
||||
Pad sink = element.GetStaticPad("sink");
|
||||
|
||||
Assert.IsFalse(src.Handle == IntPtr.Zero, "Ooops, src pad has null handle");
|
||||
Assert.IsFalse(sink.Handle == IntPtr.Zero, "Ooops, sink pad has null handle");
|
||||
Assert.IsNotNull(src, "Ooops, src pad is null");
|
||||
Assert.IsNotNull(sink, "Ooops, sink pad is null");
|
||||
|
||||
Caps srccaps = src.Caps;
|
||||
Assert.IsTrue(srccaps.IsAny, "How come src pad caps is not ANY?");
|
||||
Assert.IsFalse(src.Handle == IntPtr.Zero, "Ooops, src pad has null handle");
|
||||
Assert.IsFalse(sink.Handle == IntPtr.Zero, "Ooops, sink pad has null handle");
|
||||
|
||||
Caps sinkcaps = sink.Caps;
|
||||
Assert.IsTrue(sinkcaps.IsAny, "How come sink pad caps is not ANY?");
|
||||
}
|
||||
Caps srccaps = src.Caps;
|
||||
Assert.IsTrue(srccaps.IsAny, "How come src pad caps is not ANY?");
|
||||
|
||||
[Test]
|
||||
public void TestElementPadAccessByList()
|
||||
{
|
||||
Element element = ElementFactory.Make("identity", null);
|
||||
Assert.IsNotNull(element);
|
||||
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
|
||||
Caps sinkcaps = sink.Caps;
|
||||
Assert.IsTrue(sinkcaps.IsAny, "How come sink pad caps is not ANY?");
|
||||
}
|
||||
|
||||
bool hassink = false;
|
||||
bool hassrc = false;
|
||||
|
||||
foreach(Pad pad in element.Pads) {
|
||||
if (pad.Name == "src")
|
||||
hassrc = true;
|
||||
else if (pad.Name == "sink")
|
||||
hassink = true;
|
||||
}
|
||||
[Test]
|
||||
public void TestElementPadAccessByList()
|
||||
{
|
||||
Element element = ElementFactory.Make("identity", null);
|
||||
Assert.IsNotNull(element);
|
||||
Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
|
||||
|
||||
Assert.IsTrue(hassink, "Sink pad not found in the list");
|
||||
Assert.IsTrue(hassrc, "Src pad not found in the list");
|
||||
}
|
||||
bool hassink = false;
|
||||
bool hassrc = false;
|
||||
|
||||
foreach(Pad pad in element.Pads) {
|
||||
if (pad.Name == "src")
|
||||
hassrc = true;
|
||||
else if (pad.Name == "sink")
|
||||
hassink = true;
|
||||
}
|
||||
|
||||
Assert.IsTrue(hassink, "Sink pad not found in the list");
|
||||
Assert.IsTrue(hassrc, "Src pad not found in the list");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLink()
|
||||
|
@ -115,24 +114,24 @@ public class PadTest
|
|||
|
||||
Assert.AreEqual(src.Link(sink), PadLinkReturn.Noformat);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestGetAllowedCaps()
|
||||
{
|
||||
/*
|
||||
Gst.Buffer buffer = new Gst.Buffer();
|
||||
/*
|
||||
Gst.Buffer buffer = new Gst.Buffer();
|
||||
|
||||
try {
|
||||
Pad pbuffer = (Pad) buffer;
|
||||
Caps pcaps = pbuffer.AllowedCaps;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Assert.Fail("buffer.AllowedCaps failed");
|
||||
}
|
||||
*/
|
||||
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"); }
|
||||
// try { Caps tcaps = sink.AllowedCaps; }
|
||||
// catch (Exception) { Assert.Fail("sink.AllowedCaps failed"); }
|
||||
|
||||
Pad src = new Pad("src", PadDirection.Src);
|
||||
Assert.IsNotNull(src);
|
||||
|
@ -157,7 +156,7 @@ public class PadTest
|
|||
//Assert.Fail("event worked");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void TestPushUnlinked()
|
||||
{
|
||||
|
|
|
@ -9,140 +9,139 @@
|
|||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
using Gst;
|
||||
using Gst.CorePlugins;
|
||||
|
||||
[TestFixture]
|
||||
public class PipelineTest
|
||||
{
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
[TestFixtureSetUp]
|
||||
public void Init()
|
||||
{
|
||||
Application.Init();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestAsyncStateChangeEmpty()
|
||||
{
|
||||
Pipeline pipeline = new Pipeline(String.Empty);
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
|
||||
Assert.AreEqual(((Element)pipeline).SetState(State.Playing), StateChangeReturn.Success);
|
||||
}
|
||||
[Test]
|
||||
public void TestAsyncStateChangeEmpty()
|
||||
{
|
||||
Pipeline pipeline = new Pipeline(String.Empty);
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
|
||||
[Test]
|
||||
public void TestAsyncStateChangeFakeReady()
|
||||
{
|
||||
Pipeline pipeline = new Pipeline(String.Empty);
|
||||
Element src = ElementFactory.Make("fakesrc", null);
|
||||
Element sink = ElementFactory.Make("fakesink", null);
|
||||
Assert.AreEqual(((Element)pipeline).SetState(State.Playing), StateChangeReturn.Success);
|
||||
}
|
||||
|
||||
Bin bin = (Bin) pipeline;
|
||||
bin.Add(src, sink);
|
||||
src.Link(sink);
|
||||
[Test]
|
||||
public void TestAsyncStateChangeFakeReady()
|
||||
{
|
||||
Pipeline pipeline = new Pipeline(String.Empty);
|
||||
Element src = ElementFactory.Make("fakesrc", null);
|
||||
Element sink = ElementFactory.Make("fakesink", null);
|
||||
|
||||
Assert.AreEqual(((Element)pipeline).SetState(State.Ready), StateChangeReturn.Success);
|
||||
}
|
||||
Bin bin = (Bin) pipeline;
|
||||
bin.Add(src, sink);
|
||||
src.Link(sink);
|
||||
|
||||
[Test]
|
||||
public void TestAsyncStateChangeFake()
|
||||
{
|
||||
bool done = false;
|
||||
Pipeline pipeline = new Pipeline(String.Empty);
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
Assert.AreEqual(((Element)pipeline).SetState(State.Ready), StateChangeReturn.Success);
|
||||
}
|
||||
|
||||
Element src = ElementFactory.Make("fakesrc", null);
|
||||
Element sink = ElementFactory.Make("fakesink", null);
|
||||
[Test]
|
||||
public void TestAsyncStateChangeFake()
|
||||
{
|
||||
bool done = false;
|
||||
Pipeline pipeline = new Pipeline(String.Empty);
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
|
||||
Bin bin = (Bin) pipeline;
|
||||
bin.Add(src, sink);
|
||||
src.Link(sink);
|
||||
Element src = ElementFactory.Make("fakesrc", null);
|
||||
Element sink = ElementFactory.Make("fakesink", null);
|
||||
|
||||
Bus bus = pipeline.Bus;
|
||||
Bin bin = (Bin) pipeline;
|
||||
bin.Add(src, sink);
|
||||
src.Link(sink);
|
||||
|
||||
Assert.AreEqual(((Element) pipeline).SetState(State.Playing), StateChangeReturn.Async);
|
||||
Bus bus = pipeline.Bus;
|
||||
|
||||
while(!done) {
|
||||
State old, newState, pending;
|
||||
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;
|
||||
}
|
||||
}
|
||||
Assert.AreEqual(((Element) pipeline).SetState(State.Playing), StateChangeReturn.Async);
|
||||
|
||||
Assert.AreEqual(((Element)pipeline).SetState(State.Null), StateChangeReturn.Success);
|
||||
}
|
||||
while(!done) {
|
||||
State old, newState, pending;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Element pipeline;
|
||||
GLib.MainLoop loop;
|
||||
Assert.AreEqual(((Element)pipeline).SetState(State.Null), StateChangeReturn.Success);
|
||||
}
|
||||
|
||||
bool MessageReceived(Bus bus, Message message) {
|
||||
MessageType type = message.Type;
|
||||
Element pipeline;
|
||||
GLib.MainLoop loop;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case MessageType.StateChanged:
|
||||
{
|
||||
State old, newState, pending;
|
||||
message.ParseStateChanged(out old, out newState, out pending);
|
||||
if(message.Src == (Gst.Object) pipeline && newState == State.Playing) {
|
||||
loop.Quit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageType.Error:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
[Test]
|
||||
[Ignore("This test does not terminate")]
|
||||
public void TestBus()
|
||||
{
|
||||
pipeline = new Pipeline(String.Empty);
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
|
||||
Element src = ElementFactory.Make("fakesrc", null);
|
||||
Assert.IsNotNull(src, "Could not create fakesrc");
|
||||
Element sink = ElementFactory.Make("fakesink", null);
|
||||
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");
|
||||
|
||||
Assert.AreEqual(pipeline.SetState(State.Playing), StateChangeReturn.Async);
|
||||
bool MessageReceived(Bus bus, Message message) {
|
||||
MessageType type = message.Type;
|
||||
|
||||
loop = new GLib.MainLoop();
|
||||
loop.Run();
|
||||
switch(type)
|
||||
{
|
||||
case MessageType.StateChanged:
|
||||
{
|
||||
State old, newState, pending;
|
||||
message.ParseStateChanged(out old, out newState, out pending);
|
||||
if(message.Src == (Gst.Object) pipeline && newState == State.Playing) {
|
||||
loop.Quit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MessageType.Error:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
[Test]
|
||||
[Ignore("This test does not terminate")]
|
||||
public void TestBus()
|
||||
{
|
||||
pipeline = new Pipeline(String.Empty);
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
|
||||
Assert.AreEqual(pipeline.SetState(State.Null), StateChangeReturn.Success);
|
||||
State current, pending;
|
||||
Assert.AreEqual(pipeline.GetState(out current, out pending, Clock.TimeNone), StateChangeReturn.Success);
|
||||
Assert.AreEqual(current, State.Null, "state is not NULL but " + current);
|
||||
}
|
||||
Element src = ElementFactory.Make("fakesrc", null);
|
||||
Assert.IsNotNull(src, "Could not create fakesrc");
|
||||
Element sink = ElementFactory.Make("fakesink", null);
|
||||
Assert.IsNotNull(sink, "Could not create fakesink");
|
||||
|
||||
[Test]
|
||||
public void TestBaseTime() {
|
||||
Element pipeline = ElementFactory.Make("pipeline", "pipeline");
|
||||
FakeSrc fakesrc = FakeSrc.Make("fakesrc");
|
||||
FakeSink fakesink = FakeSink.Make("fakesink");
|
||||
Bin bin = (Bin) pipeline;
|
||||
bin.Add(src, sink);
|
||||
Assert.IsTrue(src.Link(sink), "Could not link between src and sink");
|
||||
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
Assert.IsNotNull(fakesrc, "Could not create fakesrc");
|
||||
Assert.IsNotNull(fakesink, "Could not create fakesink");
|
||||
|
||||
fakesrc.IsLive = true;
|
||||
Assert.AreEqual(pipeline.SetState(State.Playing), StateChangeReturn.Async);
|
||||
|
||||
Bin bin = (Bin) pipeline;
|
||||
bin.Add(fakesrc, fakesink);
|
||||
Assert.IsTrue(fakesrc.Link(fakesink));
|
||||
loop = new GLib.MainLoop();
|
||||
loop.Run();
|
||||
|
||||
Pad sink = fakesink.GetPad("sink");
|
||||
}
|
||||
Assert.AreEqual(pipeline.SetState(State.Null), StateChangeReturn.Success);
|
||||
State current, pending;
|
||||
Assert.AreEqual(pipeline.GetState(out current, out pending, Clock.TimeNone), StateChangeReturn.Success);
|
||||
Assert.AreEqual(current, State.Null, "state is not NULL but " + current);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBaseTime() {
|
||||
Element pipeline = ElementFactory.Make("pipeline", "pipeline");
|
||||
FakeSrc fakesrc = FakeSrc.Make("fakesrc");
|
||||
FakeSink fakesink = FakeSink.Make("fakesink");
|
||||
|
||||
Assert.IsNotNull(pipeline, "Could not create pipeline");
|
||||
Assert.IsNotNull(fakesrc, "Could not create fakesrc");
|
||||
Assert.IsNotNull(fakesink, "Could not create fakesink");
|
||||
|
||||
fakesrc.IsLive = true;
|
||||
|
||||
Bin bin = (Bin) pipeline;
|
||||
bin.Add(fakesrc, fakesink);
|
||||
Assert.IsTrue(fakesrc.Link(fakesink));
|
||||
|
||||
Pad sink = fakesink.GetStaticPad("sink");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue