summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKhaled Mohammed <khaled.mohammed@gmail.com>2006-08-20 22:37:48 +0000
committerKhaled Mohammed <khaled.mohammed@gmail.com>2006-08-20 22:37:48 +0000
commit9b5a54fe8d524cae979069488dcf28bb55aa02cb (patch)
tree39de8f13aaf0a68ba7811e22bcda3322177faa3b /tests
parent3df192045a063b56b6182e5c6a2b174743cc035b (diff)
2006/08/20 Khaled Mohammed (khaled.mohammed@gmail.com)
git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@64117 e3ebcda4-bce8-0310-ba0a-eca2169e7518
Diffstat (limited to 'tests')
-rw-r--r--tests/BinTest.cs22
-rw-r--r--tests/BufferTest.cs9
-rw-r--r--tests/PadTest.cs127
-rw-r--r--tests/PipelineTest.cs3
4 files changed, 142 insertions, 19 deletions
diff --git a/tests/BinTest.cs b/tests/BinTest.cs
index c34ce28..594ce5b 100644
--- a/tests/BinTest.cs
+++ b/tests/BinTest.cs
@@ -48,7 +48,7 @@ public class BinTest
bin.Dispose();
}
-/*
+
[Test]
public void TestGetByName()
{
@@ -61,8 +61,8 @@ public class BinTest
Assert.IsNotNull(e1);
Assert.AreEqual(e1.Name, "element-name");
- bin.Dispose();
e1.Dispose();
+ bin.Dispose();
}
[Test]
@@ -71,7 +71,7 @@ public class BinTest
Bin bin = new Bin("test-bin");
Element [] elements = new Element [] {
- ElementFactory.Make("fakesrc", "fakesrc"),
+ ElementFactory.Make("fakesrc", "fakesrc"),
ElementFactory.Make("audioconvert", "audioconvert"),
ElementFactory.Make("wavenc", "wavenc"),
ElementFactory.Make("fakesink", "fakesink")
@@ -82,30 +82,32 @@ public class BinTest
}
Assert.AreEqual(elements.Length, bin.ChildrenCount);
- Element [] children = bin.Children;
+ Element [] children = bin.Children;
- for(int i = 0; i < elements.Length; i++) {
+ for(int i = 0; i < elements.Length; i++) {
Assert.AreEqual(elements[elements.Length - i - 1], children[i]);
}
bin.Dispose();
+
+ foreach(Element e in elements)
+ e.Dispose();
}
-
+
[Test]
public void TestInterface()
{
Bin bin = new Bin(String.Empty);
Assert.IsNotNull(bin, "Could not create bin");
- Element filesrc = ElementFactory.Make("filesrc", String.Empty);
+ Element filesrc = ElementFactory.Make("filesrc", null);
Assert.IsNotNull(filesrc, "Could not create filesrc");
bin.Add(filesrc);
- bin.Dispose();
filesrc.Dispose();
-
+ bin.Dispose();
}
-*/
+
}
diff --git a/tests/BufferTest.cs b/tests/BufferTest.cs
index aeeaf21..5abcab4 100644
--- a/tests/BufferTest.cs
+++ b/tests/BufferTest.cs
@@ -29,14 +29,11 @@ public class BufferTest {
Gst.Buffer buffer = new Gst.Buffer(4);
Caps caps = Caps.FromString("audio/x-raw-int");
Assert.AreEqual(caps.Refcount, 1, "caps");
- Assert.IsNull(buffer.Caps);
+ Assert.IsNull(buffer.Caps, "buffer.Caps is null???");
buffer.Caps = caps;
Assert.AreEqual(caps.Refcount, 2, "caps");
- Assert.AreEqual(caps, buffer.Caps);
- Assert.AreEqual(caps.Refcount, 2, "caps");
-
Caps caps2 = Caps.FromString("audio/x-raw-float");
Assert.AreEqual(caps2.Refcount, 1, "caps2");
@@ -55,7 +52,7 @@ public class BufferTest {
caps.Dispose();
caps2.Dispose();
}
-
+*/
[Test]
public void TestSubbuffer()
{
@@ -87,6 +84,6 @@ public class BufferTest {
buffer.Dispose();
}
-*/
+
}
diff --git a/tests/PadTest.cs b/tests/PadTest.cs
index f942ee9..9acbbf2 100644
--- a/tests/PadTest.cs
+++ b/tests/PadTest.cs
@@ -27,7 +27,7 @@ public class PadTest
{
Application.Deinit();
}
-/*
+
[Test]
public void TestPlainCreation()
{
@@ -145,5 +145,130 @@ public class PadTest
sink.Dispose();
src.Dispose();
}
+
+ [Test]
+ public void TestRefcount()
+ {
+ Pad sink = new Pad("sink", PadDirection.Sink);
+ Assert.IsNotNull(sink, "Pad could not be created");
+
+ Pad src = new Pad("src", PadDirection.Src);
+ Assert.IsNotNull(src, "Pad could not be created");
+
+ Caps caps = Caps.FromString("foo/bar");
+
+ Assert.AreEqual(caps.Refcount, 1, "caps");
+
+ src.SetCaps(caps);
+ sink.SetCaps(caps);
+
+ Assert.AreEqual(caps.Refcount, 3, "caps");
+
+ PadLinkReturn plr = src.Link(sink);
+ Assert.AreEqual(plr, PadLinkReturn.Ok, "Pad link failed");
+
+ Assert.AreEqual(caps.Refcount, 3, "caps");
+
+ src.Unlink(sink);
+ Assert.AreEqual(caps.Refcount, 3, "caps");
+
+ src.Dispose();
+ sink.Dispose();
+ Assert.AreEqual(caps.Refcount, 1, "caps");
+
+ caps.Dispose();
+ }
+
+ [Test]
+ public void TestGetAllowedCaps()
+ {
+/*
+ Gst.Buffer buffer = new Gst.Buffer();
+
+ try {
+ Pad pbuffer = (Pad) buffer;
+ Caps pcaps = pbuffer.AllowedCaps;
+ }
+ catch (Exception ex) {
+ Assert.Fail("buffer.AllowedCaps failed");
+ }
+
+ buffer.Dispose();
*/
+ Pad sink = new Pad("sink", PadDirection.Sink);
+// try { Caps tcaps = sink.AllowedCaps; }
+// catch (Exception) { Assert.Fail("sink.AllowedCaps failed"); }
+
+ Pad src = new Pad("src", PadDirection.Src);
+ Assert.IsNotNull(src);
+ Caps caps = src.AllowedCaps;
+ Assert.IsNull(caps);
+
+ caps = Caps.FromString("foo/bar");
+
+ src.SetCaps(caps);
+ sink.SetCaps(caps);
+ Assert.AreEqual(caps.Refcount, 3, "caps");
+
+ PadLinkReturn plr = src.Link(sink);
+ Assert.AreEqual(plr, PadLinkReturn.Ok);
+
+ Caps gotcaps = src.AllowedCaps;
+ Assert.IsNotNull(gotcaps);
+ Assert.IsTrue(gotcaps.IsEqual(caps));
+
+ Assert.AreEqual(gotcaps.Refcount, 1, "gotcaps");
+ gotcaps.Dispose();
+
+ src.Unlink(sink);
+ Assert.AreEqual(caps.Refcount, 3, "caps");
+ Assert.AreEqual(src.Refcount, 1, "src");
+ Assert.AreEqual(sink.Refcount, 1, "sink");
+
+ src.Dispose();
+ sink.Dispose();
+
+ Assert.AreEqual(caps.Refcount, 1, "caps");
+ caps.Dispose();
+ }
+
+ bool ProbeHandler(Pad pad, Gst.Buffer buffer)
+ {
+ //Assert.Fail("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);
+ Assert.AreEqual(caps.Refcount, 2, "caps");
+
+ Gst.Buffer buffer = new Gst.Buffer();
+ buffer.Ref();
+ Assert.AreEqual(src.Push(buffer), FlowReturn.NotLinked);
+ Assert.AreEqual(buffer.Refcount, 1, "buffer");
+ buffer.Dispose();
+
+ ulong handler_id = src.AddBufferProbe(new Pad.BufferProbeDelegate(ProbeHandler));
+ buffer = new Gst.Buffer();
+ buffer.Ref();
+ Assert.AreEqual(src.Push(buffer), FlowReturn.Ok);
+ buffer.Dispose();
+ src.RemoveBufferProbe((uint)handler_id);
+
+ Assert.AreEqual(caps.Refcount, 2, "caps");
+ Assert.AreEqual(src.Refcount, 1, "src");
+
+ src.Dispose();
+
+ Assert.AreEqual(caps.Refcount, 1, "caps");
+ caps.Dispose();
+ }
}
diff --git a/tests/PipelineTest.cs b/tests/PipelineTest.cs
index c500cda..ebe4764 100644
--- a/tests/PipelineTest.cs
+++ b/tests/PipelineTest.cs
@@ -26,7 +26,7 @@ public class PipelineTest
{
Application.Deinit();
}
-/*
+
[Test]
public void TestAsyncStateChangeEmpty()
{
@@ -195,5 +195,4 @@ public class PipelineTest
fakesrc.Dispose();
fakesink.Dispose();
}
-*/
}