summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2009-03-26 16:13:48 +0100
committerEdward Hervey <bilboed@bilboed.com>2009-03-26 16:13:48 +0100
commit7aef2834cff525906db15b4af0ee54b723bdd083 (patch)
tree40d01d20ef337c1b04d8d9b969884b7f0aba3d9c /testsuite
parent0fd4db686bd569c1751b94e4e6c078b31c35f017 (diff)
New guint8* ArgType. Wraps the various GstAdapter methods. Fixes #576505
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/Makefile.am1
-rw-r--r--testsuite/test_adapter.py83
2 files changed, 84 insertions, 0 deletions
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index 831f5d2..35298a0 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -19,6 +19,7 @@ testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES)
$(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS)
tests = \
+ test_adapter.py \
test_bin.py \
test_buffer.py \
test_caps.py \
diff --git a/testsuite/test_adapter.py b/testsuite/test_adapter.py
new file mode 100644
index 0000000..eec78b2
--- /dev/null
+++ b/testsuite/test_adapter.py
@@ -0,0 +1,83 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# gst-python - Python bindings for GStreamer
+# Copyright (C) 2009 Edward Hervey
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+from common import gobject, gst, unittest, TestCase
+
+class AdapterTest(TestCase):
+
+ def setUp(self):
+ TestCase.setUp(self)
+ self.adapter = gst.Adapter()
+
+ def tearDown(self):
+ self.adapter = None
+ TestCase.tearDown(self)
+
+ def testAvailable(self):
+ # starts empty
+ self.assertEquals(self.adapter.available(), 0)
+ self.assertEquals(self.adapter.available_fast(), 0)
+
+ # let's give it 4 bytes
+ self.adapter.push(gst.Buffer("1234"))
+ self.assertEquals(self.adapter.available_fast(), 4)
+
+ # let's give it another 5 bytes
+ self.adapter.push(gst.Buffer("56789"))
+ # we now have 9 bytes
+ self.assertEquals(self.adapter.available(), 9)
+ # but can only do a fast take of 4 bytes (the first buffer)
+ self.assertEquals(self.adapter.available_fast(), 4)
+
+ def testPeek(self):
+ self.adapter.push(gst.Buffer("0123456789"))
+
+ # let's peek at 5 bytes
+ b = self.adapter.peek(5)
+ # it can return more than 5 bytes
+ self.assert_(len(b) >= 5)
+ self.assertEquals(b[:5], "01234")
+
+ # it's still 10 bytes big
+ self.assertEquals(self.adapter.available(), 10)
+
+ # if we try to peek more than what's available, we'll have None
+ self.assertEquals(self.adapter.peek(11), None)
+
+ def testFlush(self):
+ self.adapter.push(gst.Buffer("0123456789"))
+ self.assertEquals(self.adapter.available(), 10)
+
+ self.adapter.flush(5)
+ self.assertEquals(self.adapter.available(), 5)
+
+ # it flushed the first 5 bytes
+ self.assertEquals(self.adapter.peek(5)[:5], "56789")
+
+ self.adapter.flush(5)
+ self.assertEquals(self.adapter.available(), 0)
+
+ def testTake(self):
+ self.adapter.push(gst.Buffer("0123456789"))
+ self.assertEquals(self.adapter.available(), 10)
+
+ s = self.adapter.take(5)
+ self.assertEquals(s[:5], "01234")
+ self.assertEquals(self.adapter.available(), 5)