summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2017-05-21 17:03:48 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.com>2020-01-07 10:42:36 +0530
commitbc3e5b1206e3df44f8e3a371a0486a6889e5f32e (patch)
tree56c6ed323603ae1fa7a2c943a28f02525df46b60
parentadca3bf8f78bcf06543568c151f622c03e291d2d (diff)
test: Add test for the plugin loader
Fix #8
-rw-r--r--testsuite/meson.build14
-rw-r--r--testsuite/python/identity.py46
-rw-r--r--testsuite/test_plugin.py42
3 files changed, 102 insertions, 0 deletions
diff --git a/testsuite/meson.build b/testsuite/meson.build
index 4fb573b..3d0e993 100644
--- a/testsuite/meson.build
+++ b/testsuite/meson.build
@@ -3,6 +3,7 @@ runtests = files('runtests.py')
tests = [
['Test gst', 'test_gst.py'],
['Test fundamentals', 'test_types.py'],
+ ['Test plugins', 'test_plugin.py'],
]
pluginsdirs = []
@@ -25,10 +26,23 @@ if runcmd.returncode() != 0
error('Could not configure testsuite config file.' + runcmd.stderr())
endif
+pluginsdirs = []
+if gst_dep.type_name() == 'pkgconfig'
+ pbase = dependency('gstreamer-plugins-base-' + api_version, required : false)
+ pluginsdirs = [gst_dep.get_pkgconfig_variable('pluginsdir'),
+ pbase.get_pkgconfig_variable('pluginsdir')]
+endif
+
+pypluginsdir = [join_paths (meson.build_root(), 'plugin'), meson.current_source_dir()]
+
foreach i: tests
test_name = i.get(0)
env = environment()
env.set('GST_OVERRIDE_SRC_PATH', join_paths (meson.current_source_dir(), '..', 'gi', 'overrides'))
env.set('GST_OVERRIDE_BUILD_PATH', join_paths (meson.current_build_dir(), '..', 'gi', 'overrides'))
+ env.set('GST_PLUGIN_LOADING_WHITELIST', 'gstreamer',
+ 'gst-plugins-base@' + meson.build_root(), 'gst-python@' + meson.build_root())
+ env.set('GST_PLUGIN_PATH_1_0', meson.build_root(), pluginsdirs + pypluginsdir)
+ env.set('GST_REGISTRY', join_paths(meson.current_build_dir(), '@0@.registry'.format(test_name)))
test(test_name, python, args: [runtests, i.get(1)], env: env)
endforeach
diff --git a/testsuite/python/identity.py b/testsuite/python/identity.py
new file mode 100644
index 0000000..a591669
--- /dev/null
+++ b/testsuite/python/identity.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+
+# identity.py
+# 2016 Marianna S. Buschle <msb@qtec.com>
+#
+# Simple identity element in python
+#
+# You can run the example from the source doing from gst-python/:
+#
+# $ export GST_PLUGIN_PATH=$GST_PLUGIN_PATH:$PWD/plugin:$PWD/examples/plugins
+# $ GST_DEBUG=python:4 gst-launch-1.0 fakesrc num-buffers=10 ! identity_py ! fakesink
+
+import gi
+gi.require_version('Gst', '1.0')
+gi.require_version('GstBase', '1.0')
+
+from gi.repository import Gst, GObject, GstBase
+Gst.init(None)
+
+#
+# Simple Identity element created entirely in python
+#
+class Identity(GstBase.BaseTransform):
+ __gstmetadata__ = ('Identity Python','Transform', \
+ 'Simple identity element written in python', 'Marianna S. Buschle')
+
+ __gsttemplates__ = (Gst.PadTemplate.new("src",
+ Gst.PadDirection.SRC,
+ Gst.PadPresence.ALWAYS,
+ Gst.Caps.new_any()),
+ Gst.PadTemplate.new("sink",
+ Gst.PadDirection.SINK,
+ Gst.PadPresence.ALWAYS,
+ Gst.Caps.new_any()))
+
+ def __init__(self):
+ self.transformed = False
+
+ def do_transform_ip(self, buffer):
+ self.transformed = True
+ return Gst.FlowReturn.OK
+
+GObject.type_register(Identity)
+__gstelementfactory__ = ("test_identity_py", Gst.Rank.NONE, Identity)
diff --git a/testsuite/test_plugin.py b/testsuite/test_plugin.py
new file mode 100644
index 0000000..fb513d1
--- /dev/null
+++ b/testsuite/test_plugin.py
@@ -0,0 +1,42 @@
+# -*- Mode: Python -*-
+# vi:si:et:sw=4:sts=4:ts=4
+#
+# gst-python - Python bindings for GStreamer
+# Copyright (C) 2007 Johan Dahlin
+#
+# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import overrides_hack
+overrides_hack
+
+from common import TestCase, unittest
+
+import gi
+gi.require_version("Gst", "1.0")
+from gi.repository import Gst
+
+
+class TestPlugin(TestCase):
+ def testLoad(self):
+ Gst.init(None)
+ p = Gst.parse_launch ("fakesrc ! test_identity_py name=id ! fakesink")
+ assert p.get_by_name("id").transformed == False
+ p.set_state(Gst.State.PLAYING)
+ p.get_state(Gst.CLOCK_TIME_NONE)
+ p.set_state(Gst.State.NULL)
+ assert p.get_by_name("id").transformed == True
+
+if __name__ == "__main__":
+ unittest.main()