summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-20 10:19:49 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-09-20 10:22:16 +0200
commit80a5794fc1eef8f54b21b9792cd1fb6f85fb7df0 (patch)
tree58c0ab5fefd51af90da29e0e26becc6db96018a2 /tests
parentbd9052c00a0088b04f177ccdb38c0844d1bcfd07 (diff)
Fix indention everywhere
Diffstat (limited to 'tests')
-rw-r--r--tests/ApplicationTest.cs34
-rw-r--r--tests/BinTest.cs256
-rw-r--r--tests/BufferTest.cs135
-rw-r--r--tests/CapsTest.cs140
-rw-r--r--tests/ElementTest.cs420
-rw-r--r--tests/MessageTest.cs35
-rw-r--r--tests/PadTest.cs295
-rw-r--r--tests/PipelineTest.cs152
8 files changed, 707 insertions, 760 deletions
diff --git a/tests/ApplicationTest.cs b/tests/ApplicationTest.cs
index 9a1ce97..73502ac 100644
--- a/tests/ApplicationTest.cs
+++ b/tests/ApplicationTest.cs
@@ -11,25 +11,21 @@ using System;
using NUnit.Framework;
[TestFixture]
-public class ApplicationTest
-{
- [Test]
- public void Init()
- {
- Gst.Application.Init();
- }
+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 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 InitArgsCheck() {
+ string [] args = { "arg_a", "arg_b" };
+ Gst.Application.InitCheck ("gstreamer-sharp-test", ref args);
+ }
}
diff --git a/tests/BinTest.cs b/tests/BinTest.cs
index f64ac30..598771a 100644
--- a/tests/BinTest.cs
+++ b/tests/BinTest.cs
@@ -14,136 +14,128 @@ using Gst;
using Gst.CorePlugins;
[TestFixture]
-public class BinTest
-{
- [TestFixtureSetUp]
- public void Init()
- {
- Application.Init();
- }
-
- [Test]
- public void TestAdd()
- {
- Bin bin = new Bin("test-bin");
- Element e1 = new FakeSrc("fakesrc");
- Element e2 = new FakeSink("fakesink");
-
- Assert.IsNotNull(bin, "Could not create bin");
- Assert.IsNotNull(e1, "Could not create fakesrc");
- Assert.IsNotNull(e2, "Could not create fakesink");
-
- bin.Add(e1, e2);
-
- 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]
- 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 TestGetChildByIndex()
- {
- 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 TestElements()
- {
- Bin bin = new Bin("test-bin");
-
- Element [] elements = new Element [] {
- new CapsFilter(),
- new MultiQueue(),
- new Queue(),
- new Tee(),
- new TypeFindElement()
- };
-
- bin.Add(elements);
- CollectionAssert.AreEquivalent(elements, bin.Elements);
- CollectionAssert.AreEquivalent(elements, bin.ElementsRecurse);
- 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]
- public void TestGhostPad()
- {
- new MyBin ();
- }
+public class BinTest {
+ [TestFixtureSetUp]
+ public void Init() {
+ Application.Init();
+ }
+
+ [Test]
+ public void TestAdd() {
+ Bin bin = new Bin ("test-bin");
+ Element e1 = new FakeSrc ("fakesrc");
+ Element e2 = new FakeSink ("fakesink");
+
+ Assert.IsNotNull (bin, "Could not create bin");
+ Assert.IsNotNull (e1, "Could not create fakesrc");
+ Assert.IsNotNull (e2, "Could not create fakesink");
+
+ bin.Add (e1, e2);
+
+ 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]
+ 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 TestGetChildByIndex() {
+ 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 TestElements() {
+ Bin bin = new Bin ("test-bin");
+
+ Element [] elements = new Element [] {
+ new CapsFilter(),
+ new MultiQueue(),
+ new Queue(),
+ new Tee(),
+ new TypeFindElement()
+ };
+
+ bin.Add (elements);
+ CollectionAssert.AreEquivalent (elements, bin.Elements);
+ CollectionAssert.AreEquivalent (elements, bin.ElementsRecurse);
+ 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]
+ public void TestGhostPad() {
+ new MyBin ();
+ }
}
diff --git a/tests/BufferTest.cs b/tests/BufferTest.cs
index f5624aa..b0f2d70 100644
--- a/tests/BufferTest.cs
+++ b/tests/BufferTest.cs
@@ -10,75 +10,68 @@ using NUnit.Framework;
using Gst;
[TestFixture]
-public class BufferTest
-{
- [TestFixtureSetUp]
- public void 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]
- public void TestSubbuffer()
- {
- Gst.Buffer buffer = new Gst.Buffer(4);
- Gst.Buffer sub = buffer.CreateSub(1, 2);
- Assert.IsNotNull(sub);
- Assert.AreEqual(sub.Size, 2, "subbuffer has wrong size");
- }
-
- [Test]
- public void TestIsSpanFast()
- {
- Gst.Buffer buffer = new Gst.Buffer(4);
-
- Gst.Buffer sub1 = buffer.CreateSub(0, 2);
- Assert.IsNotNull(sub1, "CreateSub of buffer returned null");
-
- 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");
- }
-
- private void ArrayIsEqual (byte[] a, byte[] b)
- {
- Assert.IsTrue (a.Length == b.Length);
- for (int i = 0; i < a.Length; i++)
- Assert.IsTrue (a[i] == b[i]);
- }
-
- [Test]
- public void TestBufferData()
- {
- byte[] data = new byte[] {0, 1, 2, 3, 4, 5};
-
- Gst.Buffer buffer = new Gst.Buffer (data);
-
- ArrayIsEqual (data, buffer.Data);
- for (uint i = 0; i < buffer.Size; i++)
- Assert.IsTrue (buffer[i] == data[i]);
-
- }
+public class BufferTest {
+ [TestFixtureSetUp]
+ public void 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]
+ public void TestSubbuffer() {
+ Gst.Buffer buffer = new Gst.Buffer (4);
+ Gst.Buffer sub = buffer.CreateSub (1, 2);
+ Assert.IsNotNull (sub);
+ Assert.AreEqual (sub.Size, 2, "subbuffer has wrong size");
+ }
+
+ [Test]
+ public void TestIsSpanFast() {
+ Gst.Buffer buffer = new Gst.Buffer (4);
+
+ Gst.Buffer sub1 = buffer.CreateSub (0, 2);
+ Assert.IsNotNull (sub1, "CreateSub of buffer returned null");
+
+ 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");
+ }
+
+ private void ArrayIsEqual (byte[] a, byte[] b) {
+ Assert.IsTrue (a.Length == b.Length);
+ for (int i = 0; i < a.Length; i++)
+ Assert.IsTrue (a[i] == b[i]);
+ }
+
+ [Test]
+ public void TestBufferData() {
+ byte[] data = new byte[] {0, 1, 2, 3, 4, 5};
+
+ Gst.Buffer buffer = new Gst.Buffer (data);
+
+ ArrayIsEqual (data, buffer.Data);
+ for (uint i = 0; i < buffer.Size; i++)
+ Assert.IsTrue (buffer[i] == data[i]);
+
+ }
}
diff --git a/tests/CapsTest.cs b/tests/CapsTest.cs
index 23598f4..826098c 100644
--- a/tests/CapsTest.cs
+++ b/tests/CapsTest.cs
@@ -3,7 +3,7 @@
//
// Authors:
// Michael Dominic K. (michaldominik@gmail.com)
-//
+//
// (C) 2006 Novell, Inc.
//
@@ -12,89 +12,83 @@ using NUnit.Framework;
using Gst;
[TestFixture]
-public class CapsTest
-{
- [TestFixtureSetUp]
- public void Init()
- {
- Application.Init();
- }
+public class CapsTest {
+ [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?!");
- Caps caps4 = Caps.FromString("video/x-raw-yuv, " +
- "format=(fourcc)I420, " +
- "width=(int)640; " +
- "video/x-raw-yuv, " +
- "format=(fourcc)I420, " +
- "height=(int)480");
- Assert.IsTrue(caps3.IsEqual(caps4));
- }
+ Caps caps4 = Caps.FromString ("video/x-raw-yuv, " +
+ "format=(fourcc)I420, " +
+ "width=(int)640; " +
+ "video/x-raw-yuv, " +
+ "format=(fourcc)I420, " +
+ "height=(int)480");
+ Assert.IsTrue (caps3.IsEqual (caps4));
+ }
}
diff --git a/tests/ElementTest.cs b/tests/ElementTest.cs
index 5a8c0df..d9ff93a 100644
--- a/tests/ElementTest.cs
+++ b/tests/ElementTest.cs
@@ -13,217 +13,211 @@ using Gst;
using Gst.GLib;
[TestFixture]
-public class ElementTest
-{
- [TestFixtureSetUp]
- public void Init()
- {
- Application.Init();
- }
-
- [Test]
- public void TestLinkNoPads()
- {
- Element src = new Bin("src");
- Element sink = new Bin("sink");
-
- Assert.IsFalse(src.Link(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]
- public void TestAddRemovePad()
- {
- new PadAddElement ();
- }
-
- [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);
- }
-
- public class TestSubclassesApp {
- static MainLoop loop;
-
- public class MySrc : Gst.Element {
- public MySrc () : base () {
- Init ();
- }
-
- public MySrc (IntPtr raw) : base (raw) {
- Init ();
- }
-
- private Pad src;
- private uint nbuffers = 0;
-
- private void Init () {
- src = new Pad (templ, "src");
- AddPad (src);
- }
-
- static Caps caps = Caps.FromString ("my/dummy-data");
-
- private void loop () {
- Gst.Buffer buf = new Gst.Buffer ();
- buf.Caps = caps;
- Gst.FlowReturn ret = src.Push (buf);
- nbuffers++;
-
- Assert.AreEqual (ret, Gst.FlowReturn.Ok);
- if (ret != Gst.FlowReturn.Ok) {
- src.StopTask ();
- this.PostMessage (Message.NewError (this, CoreError.Failed, "Oh no"));
- }
-
- if (nbuffers == 10) {
- Assert.IsTrue (src.PushEvent (Gst.Event.NewEos ()));
- src.PauseTask ();
- }
- }
-
- protected override StateChangeReturn OnChangeState (StateChange transition) {
- if (transition == StateChange.ReadyToPaused)
- src.StartTask (loop);
- else if (transition == StateChange.PausedToReady)
- src.StopTask ();
-
- return StateChangeReturn.Success;
- }
-
- static PadTemplate templ = new PadTemplate ("src", Gst.PadDirection.Src, Gst.PadPresence.Always, Caps.FromString ("my/dummy-data"));
-
- public static bool Register () {
- SetDetails ( (GType) typeof (MySrc), "long", "klass", "desc", "author");
- AddPadTemplate ( (GType) typeof (MySrc), templ);
- return ElementFactory.Register (null, "mysrc", (uint) Gst.Rank.None, (GType) typeof (MySrc));
- }
- }
-
- public class MySink : Gst.Element {
- public MySink () : base () {
- Init ();
- }
-
- public MySink (IntPtr raw) : base (raw) {
- Init ();
- }
-
- Gst.FlowReturn on_chain (Gst.Pad pad, Gst.Buffer buffer) {
- Assert.IsNotNull (buffer);
- return Gst.FlowReturn.Ok;
- }
-
- bool on_event (Gst.Pad pad, Gst.Event evnt) {
- if (evnt.Type == Gst.EventType.Eos) {
- this.PostMessage (Message.NewEos (this));
- }
-
- return true;
- }
-
- private void Init () {
- Pad pad = new Pad (templ, "sink");
- pad.ChainFunction = on_chain;
- pad.EventFunction = on_event;
- AddPad (pad);
- }
-
- static PadTemplate templ = new PadTemplate ("sink", Gst.PadDirection.Sink, Gst.PadPresence.Always, Caps.FromString ("my/dummy-data"));
-
- public static bool Register () {
- SetDetails ( (GType) typeof (MySink), "long", "klass", "desc", "author");
- AddPadTemplate ( (GType) typeof (MySink), templ);
-
- return ElementFactory.Register (null, "mysink", (uint) Gst.Rank.None, (GType) typeof (MySink));
- }
- }
-
- private static bool BusCb (Bus bus, Message message) {
- switch (message.Type) {
- case MessageType.Error:
- Enum err;
- string msg;
-
- message.ParseError (out err, out msg);
- Assert.Fail (String.Format ("Error message: {0}", msg));
- loop.Quit ();
- break;
- case MessageType.Eos:
- loop.Quit ();
- break;
- }
- return true;
- }
-
- public static void Run () {
-
- MySrc.Register ();
- MySink.Register ();
-
- MySrc mysrc = Gst.ElementFactory.Make ("mysrc") as MySrc;
- MySink mysink = Gst.ElementFactory.Make ("mysink") as MySink;
-
- Gst.Pipeline pipeline = new Pipeline ("pipeline");
- pipeline.Add (mysrc, mysink);
- Assert.IsTrue (mysrc.Link (mysink));
-
- loop = new MainLoop ();
-
- pipeline.Bus.AddWatch (new BusFunc (BusCb));
- pipeline.SetState (Gst.State.Playing);
-
- loop.Run ();
-
- pipeline.SetState (Gst.State.Null);
- }
- }
-
- [Test]
- public void TestSubclasses ()
- {
- TestSubclassesApp.Run ();
- }
+public class ElementTest {
+ [TestFixtureSetUp]
+ public void Init() {
+ Application.Init();
+ }
+
+ [Test]
+ public void TestLinkNoPads() {
+ Element src = new Bin ("src");
+ Element sink = new Bin ("sink");
+
+ Assert.IsFalse (src.Link (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]
+ public void TestAddRemovePad() {
+ new PadAddElement ();
+ }
+
+ [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);
+ }
+
+ public class TestSubclassesApp {
+ static MainLoop loop;
+
+ public class MySrc : Gst.Element {
+ public MySrc () : base () {
+ Init ();
+ }
+
+ public MySrc (IntPtr raw) : base (raw) {
+ Init ();
+ }
+
+ private Pad src;
+ private uint nbuffers = 0;
+
+ private void Init () {
+ src = new Pad (templ, "src");
+ AddPad (src);
+ }
+
+ static Caps caps = Caps.FromString ("my/dummy-data");
+
+ private void loop () {
+ Gst.Buffer buf = new Gst.Buffer ();
+ buf.Caps = caps;
+ Gst.FlowReturn ret = src.Push (buf);
+ nbuffers++;
+
+ Assert.AreEqual (ret, Gst.FlowReturn.Ok);
+ if (ret != Gst.FlowReturn.Ok) {
+ src.StopTask ();
+ this.PostMessage (Message.NewError (this, CoreError.Failed, "Oh no"));
+ }
+
+ if (nbuffers == 10) {
+ Assert.IsTrue (src.PushEvent (Gst.Event.NewEos ()));
+ src.PauseTask ();
+ }
+ }
+
+ protected override StateChangeReturn OnChangeState (StateChange transition) {
+ if (transition == StateChange.ReadyToPaused)
+ src.StartTask (loop);
+ else if (transition == StateChange.PausedToReady)
+ src.StopTask ();
+
+ return StateChangeReturn.Success;
+ }
+
+ static PadTemplate templ = new PadTemplate ("src", Gst.PadDirection.Src, Gst.PadPresence.Always, Caps.FromString ("my/dummy-data"));
+
+ public static bool Register () {
+ SetDetails ( (GType) typeof (MySrc), "long", "klass", "desc", "author");
+ AddPadTemplate ( (GType) typeof (MySrc), templ);
+ return ElementFactory.Register (null, "mysrc", (uint) Gst.Rank.None, (GType) typeof (MySrc));
+ }
+ }
+
+ public class MySink : Gst.Element {
+ public MySink () : base () {
+ Init ();
+ }
+
+ public MySink (IntPtr raw) : base (raw) {
+ Init ();
+ }
+
+ Gst.FlowReturn on_chain (Gst.Pad pad, Gst.Buffer buffer) {
+ Assert.IsNotNull (buffer);
+ return Gst.FlowReturn.Ok;
+ }
+
+ bool on_event (Gst.Pad pad, Gst.Event evnt) {
+ if (evnt.Type == Gst.EventType.Eos) {
+ this.PostMessage (Message.NewEos (this));
+ }
+
+ return true;
+ }
+
+ private void Init () {
+ Pad pad = new Pad (templ, "sink");
+ pad.ChainFunction = on_chain;
+ pad.EventFunction = on_event;
+ AddPad (pad);
+ }
+
+ static PadTemplate templ = new PadTemplate ("sink", Gst.PadDirection.Sink, Gst.PadPresence.Always, Caps.FromString ("my/dummy-data"));
+
+ public static bool Register () {
+ SetDetails ( (GType) typeof (MySink), "long", "klass", "desc", "author");
+ AddPadTemplate ( (GType) typeof (MySink), templ);
+
+ return ElementFactory.Register (null, "mysink", (uint) Gst.Rank.None, (GType) typeof (MySink));
+ }
+ }
+
+ private static bool BusCb (Bus bus, Message message) {
+ switch (message.Type) {
+ case MessageType.Error:
+ Enum err;
+ string msg;
+
+ message.ParseError (out err, out msg);
+ Assert.Fail (String.Format ("Error message: {0}", msg));
+ loop.Quit ();
+ break;
+ case MessageType.Eos:
+ loop.Quit ();
+ break;
+ }
+ return true;
+ }
+
+ public static void Run () {
+
+ MySrc.Register ();
+ MySink.Register ();
+
+ MySrc mysrc = Gst.ElementFactory.Make ("mysrc") as MySrc;
+ MySink mysink = Gst.ElementFactory.Make ("mysink") as MySink;
+
+ Gst.Pipeline pipeline = new Pipeline ("pipeline");
+ pipeline.Add (mysrc, mysink);
+ Assert.IsTrue (mysrc.Link (mysink));
+
+ loop = new MainLoop ();
+
+ pipeline.Bus.AddWatch (new BusFunc (BusCb));
+ pipeline.SetState (Gst.State.Playing);
+
+ loop.Run ();
+
+ pipeline.SetState (Gst.State.Null);
+ }
+ }
+
+ [Test]
+ public void TestSubclasses () {
+ TestSubclassesApp.Run ();
+ }
}
diff --git a/tests/MessageTest.cs b/tests/MessageTest.cs
index 59d4ca5..3494068 100644
--- a/tests/MessageTest.cs
+++ b/tests/MessageTest.cs
@@ -9,25 +9,22 @@ using System;
using NUnit.Framework;
using Gst;
-public class MessageTest
-{
- [TestFixtureSetUp]
- public void Init()
- {
- Application.Init();
- }
+public class MessageTest {
+ [TestFixtureSetUp]
+ public void Init() {
+ Application.Init();
+ }
- [Test]
- public void TestParsing()
- {
- Message message = Message.NewEos(null);
- Assert.IsNotNull(message);
- Assert.AreEqual(message.Type, MessageType.Eos);
- Assert.IsNull(message.Src);
+ [Test]
+ public void TestParsing() {
+ Message message = Message.NewEos (null);
+ Assert.IsNotNull (message);
+ Assert.AreEqual (message.Type, MessageType.Eos);
+ Assert.IsNull (message.Src);
- message = Message.NewError(null, CoreError.TooLazy);
- Assert.IsNotNull(message);
- Assert.AreEqual(message.Type, MessageType.Error);
- Assert.IsNull(message.Src);
- }
+ message = Message.NewError (null, CoreError.TooLazy);
+ Assert.IsNotNull (message);
+ Assert.AreEqual (message.Type, MessageType.Error);
+ Assert.IsNull (message.Src);
+ }
}
diff --git a/tests/PadTest.cs b/tests/PadTest.cs
index 461e7c7..b5a81fd 100644
--- a/tests/PadTest.cs
+++ b/tests/PadTest.cs
@@ -4,7 +4,7 @@
// Authors:
// Michael Dominic K. (michaldominik@gmail.com)
// Khaled Mohammed (khaled.mohammed@gmail.com)
-//
+//
// (C) 2006 Novell, Inc.
//
@@ -13,156 +13,145 @@ using NUnit.Framework;
using Gst;
[TestFixture]
-public class PadTest
-{
- [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);
-
- 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.AreEqual(PadDirection.Src, src.Direction);
- Assert.AreEqual(PadDirection.Sink, sink.Direction);
- }
-
- public static Caps PadGetCapsStub(Pad pad)
- {
- return Caps.FromString("video/x-raw-yuv");
- }
-
- [Test]
- public void TestFuncAssigning()
- {
- Pad src = new Pad("src", PadDirection.Src);
- src.GetCapsFunction = new PadGetCapsFunction(PadGetCapsStub);
-
- Caps caps = src.Caps;
-
- 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 ());
- }
-
- [Test]
- public void TestElementPadAccessByName()
- {
- Element element = ElementFactory.Make("identity");
- Assert.IsNotNull(element);
- Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
-
- Pad src = element.GetStaticPad("src");
- Pad sink = element.GetStaticPad("sink");
-
- Assert.IsNotNull(src, "Ooops, src pad is null");
- Assert.IsNotNull(sink, "Ooops, sink pad is null");
-
- 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 srccaps = src.Caps;
- Assert.IsTrue(srccaps.IsAny, "How come src pad caps is not ANY?");
-
- Caps sinkcaps = sink.Caps;
- Assert.IsTrue(sinkcaps.IsAny, "How come sink pad caps is not ANY?");
- }
-
- [Test]
- public void TestElementPadAccessByList()
- {
- Element element = ElementFactory.Make("identity");
- Assert.IsNotNull(element);
- Assert.IsFalse(element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
-
- 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()
- {
- Pad src = new Pad("source", PadDirection.Src);
- Assert.IsNotNull(src, "Pad could not be created");
-
- string name = src.Name;
- Assert.AreEqual(name, "source");
-
- Pad sink = new Pad("sink", PadDirection.Sink);
- Assert.IsNotNull(sink, "Pad could not be created");
-
- Assert.AreEqual(src.Link(sink), PadLinkReturn.Noformat);
- }
-
- [Test]
- public void TestGetAllowedCaps()
- {
- Caps caps;
-
- Pad sink = new Pad("sink", PadDirection.Sink);
- caps = sink.AllowedCaps;
- Assert.IsNull(caps);
-
- Pad src = new Pad("src", PadDirection.Src);
- caps = src.AllowedCaps;
- Assert.IsNull(caps);
-
- caps = Caps.FromString("foo/bar");
-
- src.SetCaps(caps);
- sink.SetCaps(caps);
-
- PadLinkReturn plr = src.Link(sink);
- Assert.AreEqual(plr, PadLinkReturn.Ok);
-
- Caps gotcaps = src.AllowedCaps;
- Assert.IsNotNull(gotcaps);
- Assert.IsTrue(gotcaps.IsEqual(caps));
- }
-
- bool ProbeHandler(Pad pad, Gst.Buffer buffer)
- {
- //Console.WriteLine("event worked");
- return false;
- }
-
- [Test]
- public void TestPushUnlinked()
- {
- Pad src = new Pad("src", PadDirection.Src);
- Assert.IsNotNull(src, "Could not create src");
- Caps caps = src.AllowedCaps;
- Assert.IsNull(caps);
-
- caps = Caps.FromString("foo/bar");
- src.SetCaps(caps);
-
- Gst.Buffer buffer = new Gst.Buffer();
- Assert.AreEqual(src.Push(buffer), FlowReturn.NotLinked);
-
- ulong handler_id = src.AddBufferProbe(new PadBufferProbeCallback(ProbeHandler));
- buffer = new Gst.Buffer(new byte[] {0});
- FlowReturn flowreturn = src.Push(buffer);
- Assert.AreEqual(flowreturn, FlowReturn.Ok);
- }
+public class PadTest {
+ [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);
+
+ 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.AreEqual (PadDirection.Src, src.Direction);
+ Assert.AreEqual (PadDirection.Sink, sink.Direction);
+ }
+
+ public static Caps PadGetCapsStub (Pad pad) {
+ return Caps.FromString ("video/x-raw-yuv");
+ }
+
+ [Test]
+ public void TestFuncAssigning() {
+ Pad src = new Pad ("src", PadDirection.Src);
+ src.GetCapsFunction = new PadGetCapsFunction (PadGetCapsStub);
+
+ Caps caps = src.Caps;
+
+ 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 ());
+ }
+
+ [Test]
+ public void TestElementPadAccessByName() {
+ Element element = ElementFactory.Make ("identity");
+ Assert.IsNotNull (element);
+ Assert.IsFalse (element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
+
+ Pad src = element.GetStaticPad ("src");
+ Pad sink = element.GetStaticPad ("sink");
+
+ Assert.IsNotNull (src, "Ooops, src pad is null");
+ Assert.IsNotNull (sink, "Ooops, sink pad is null");
+
+ 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 srccaps = src.Caps;
+ Assert.IsTrue (srccaps.IsAny, "How come src pad caps is not ANY?");
+
+ Caps sinkcaps = sink.Caps;
+ Assert.IsTrue (sinkcaps.IsAny, "How come sink pad caps is not ANY?");
+ }
+
+ [Test]
+ public void TestElementPadAccessByList() {
+ Element element = ElementFactory.Make ("identity");
+ Assert.IsNotNull (element);
+ Assert.IsFalse (element.Handle == IntPtr.Zero, "Ooops, identity element has null handle");
+
+ 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() {
+ Pad src = new Pad ("source", PadDirection.Src);
+ Assert.IsNotNull (src, "Pad could not be created");
+
+ string name = src.Name;
+ Assert.AreEqual (name, "source");
+
+ Pad sink = new Pad ("sink", PadDirection.Sink);
+ Assert.IsNotNull (sink, "Pad could not be created");
+
+ Assert.AreEqual (src.Link (sink), PadLinkReturn.Noformat);
+ }
+
+ [Test]
+ public void TestGetAllowedCaps() {
+ Caps caps;
+
+ Pad sink = new Pad ("sink", PadDirection.Sink);
+ caps = sink.AllowedCaps;
+ Assert.IsNull (caps);
+
+ Pad src = new Pad ("src", PadDirection.Src);
+ caps = src.AllowedCaps;
+ Assert.IsNull (caps);
+
+ caps = Caps.FromString ("foo/bar");
+
+ src.SetCaps (caps);
+ sink.SetCaps (caps);
+
+ PadLinkReturn plr = src.Link (sink);
+ Assert.AreEqual (plr, PadLinkReturn.Ok);
+
+ Caps gotcaps = src.AllowedCaps;
+ Assert.IsNotNull (gotcaps);
+ Assert.IsTrue (gotcaps.IsEqual (caps));
+ }
+
+ bool ProbeHandler (Pad pad, Gst.Buffer buffer) {
+ //Console.WriteLine("event worked");
+ return false;
+ }
+
+ [Test]
+ public void TestPushUnlinked() {
+ Pad src = new Pad ("src", PadDirection.Src);
+ Assert.IsNotNull (src, "Could not create src");
+ Caps caps = src.AllowedCaps;
+ Assert.IsNull (caps);
+
+ caps = Caps.FromString ("foo/bar");
+ src.SetCaps (caps);
+
+ Gst.Buffer buffer = new Gst.Buffer();
+ Assert.AreEqual (src.Push (buffer), FlowReturn.NotLinked);
+
+ ulong handler_id = src.AddBufferProbe (new PadBufferProbeCallback (ProbeHandler));
+ buffer = new Gst.Buffer (new byte[] {0});
+ FlowReturn flowreturn = src.Push (buffer);
+ Assert.AreEqual (flowreturn, FlowReturn.Ok);
+ }
}
diff --git a/tests/PipelineTest.cs b/tests/PipelineTest.cs
index 91427c2..590f7b6 100644
--- a/tests/PipelineTest.cs
+++ b/tests/PipelineTest.cs
@@ -3,7 +3,7 @@
//
// Authors
// Khaled Mohammed < khaled.mohammed@gmail.com >
-//
+//
// (C) 2006
//
@@ -13,160 +13,152 @@ using Gst;
using Gst.CorePlugins;
[TestFixture]
-public class PipelineTest
-{
+public class PipelineTest {
[TestFixtureSetUp]
- public void Init()
- {
+ public void Init() {
Application.Init();
}
- [Test]
- public void TestPipeline()
- {
- Pipeline pipeline = new Pipeline();
- 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]
+ public void TestPipeline() {
+ Pipeline pipeline = new Pipeline();
+ 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]
- public void TestAsyncStateChangeEmpty()
- {
+ public void TestAsyncStateChangeEmpty() {
Pipeline pipeline = new Pipeline();
- Assert.IsNotNull(pipeline, "Could not create pipeline");
+ Assert.IsNotNull (pipeline, "Could not create pipeline");
- Assert.AreEqual(((Element)pipeline).SetState(State.Playing), StateChangeReturn.Success);
+ Assert.AreEqual ( ( (Element) pipeline).SetState (State.Playing), StateChangeReturn.Success);
}
[Test]
- public void TestAsyncStateChangeFakeReady()
- {
+ public void TestAsyncStateChangeFakeReady() {
Pipeline pipeline = new Pipeline();
- Element src = ElementFactory.Make("fakesrc");
- Element sink = ElementFactory.Make("fakesink");
+ Element src = ElementFactory.Make ("fakesrc");
+ Element sink = ElementFactory.Make ("fakesink");
Bin bin = (Bin) pipeline;
- bin.Add(src, sink);
- src.Link(sink);
+ bin.Add (src, sink);
+ src.Link (sink);
- Assert.AreEqual(((Element)pipeline).SetState(State.Ready), StateChangeReturn.Success);
+ Assert.AreEqual ( ( (Element) pipeline).SetState (State.Ready), StateChangeReturn.Success);
}
[Test]
- public void TestAsyncStateChangeFake()
- {
+ public void TestAsyncStateChangeFake() {
bool done = false;
Pipeline pipeline = new Pipeline();
- Assert.IsNotNull(pipeline, "Could not create pipeline");
+ Assert.IsNotNull (pipeline, "Could not create pipeline");
- Element src = ElementFactory.Make("fakesrc");
- Element sink = ElementFactory.Make("fakesink");
+ Element src = ElementFactory.Make ("fakesrc");
+ Element sink = ElementFactory.Make ("fakesink");
Bin bin = (Bin) pipeline;
- bin.Add(src, sink);
- src.Link(sink);
+ bin.Add (src, sink);
+ src.Link (sink);
Bus bus = pipeline.Bus;
- Assert.AreEqual(((Element) pipeline).SetState(State.Playing), StateChangeReturn.Async);
+ Assert.AreEqual ( ( (Element) pipeline).SetState (State.Playing), StateChangeReturn.Async);
- while(!done) {
+ while (!done) {
State old, newState, pending;
- Message message = bus.Poll(MessageType.StateChanged, -1);
- if(message != null) {
- message.ParseStateChanged(out old, out newState, out pending);
- if(message.Src == (Gst.Object) pipeline && newState == State.Playing)
+ Message message = bus.Poll (MessageType.StateChanged, -1);
+ if (message != null) {
+ message.ParseStateChanged (out old, out newState, out pending);
+ if (message.Src == (Gst.Object) pipeline && newState == State.Playing)
done = true;
}
}
- Assert.AreEqual(((Element)pipeline).SetState(State.Null), StateChangeReturn.Success);
+ Assert.AreEqual ( ( (Element) pipeline).SetState (State.Null), StateChangeReturn.Success);
}
Element pipeline;
Gst.GLib.MainLoop loop;
- bool MessageReceived(Bus bus, Message message) {
+ bool MessageReceived (Bus bus, Message message) {
MessageType type = message.Type;
- 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;
+ 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;
+ default:
+ break;
}
return true;
}
[Test]
- public void TestBusAddWatch()
- {
- TestBusCallback(true);
+ public void TestBusAddWatch() {
+ TestBusCallback (true);
}
[Test]
- public void TestBusAddSignalWatch()
- {
- TestBusCallback(false);
+ public void TestBusAddSignalWatch() {
+ TestBusCallback (false);
}
- public void TestBusCallback(bool use_AddWatch)
- {
+ public void TestBusCallback (bool use_AddWatch) {
pipeline = new Pipeline();
- Assert.IsNotNull(pipeline, "Could not create pipeline");
+ Assert.IsNotNull (pipeline, "Could not create pipeline");
- Element src = ElementFactory.Make("fakesrc");
- Assert.IsNotNull(src, "Could not create fakesrc");
- Element sink = ElementFactory.Make("fakesink");
- Assert.IsNotNull(sink, "Could not create fakesink");
+ Element src = ElementFactory.Make ("fakesrc");
+ Assert.IsNotNull (src, "Could not create fakesrc");
+ 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");
+ 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));
+ pipeline.Bus.AddWatch (new BusFunc (MessageReceived));
else {
pipeline.Bus.AddSignalWatch();
- pipeline.Bus.Message += delegate (object o, MessageArgs args) {MessageReceived(null, args.Message);};
+ pipeline.Bus.Message += delegate (object o, MessageArgs args) {
+ MessageReceived (null, args.Message);
+ };
}
- Assert.AreEqual(pipeline.SetState(State.Playing), StateChangeReturn.Async);
+ Assert.AreEqual (pipeline.SetState (State.Playing), StateChangeReturn.Async);
loop = new Gst.GLib.MainLoop();
loop.Run();
- Assert.AreEqual(pipeline.SetState(State.Null), StateChangeReturn.Success);
+ 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);
+ 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");
+ 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");
+ 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));
+ bin.Add (fakesrc, fakesink);
+ Assert.IsTrue (fakesrc.Link (fakesink));
- Pad sink = fakesink.GetStaticPad("sink");
+ Pad sink = fakesink.GetStaticPad ("sink");
}
}