mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-07 06:52:41 +00:00
added check test suite for the controller fixed a doc typo
Original commit message from CVS: added check test suite for the controller fixed a doc typo
This commit is contained in:
parent
722f83a8fc
commit
b3034dba54
9 changed files with 518 additions and 20 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-08-03 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
|
* check/Makefile.am:
|
||||||
|
* check/gst-libs/controller.c:
|
||||||
|
* libs/gst/controller/gst-controller.c:
|
||||||
|
(gst_controller_new_valist):
|
||||||
|
added check test suite for the controller
|
||||||
|
* gst/base/gstpushsrc.c:
|
||||||
|
fixed a doc typo
|
||||||
|
|
||||||
2005-08-03 Stefan Kost <ensonic@users.sf.net>
|
2005-08-03 Stefan Kost <ensonic@users.sf.net>
|
||||||
|
|
||||||
* docs/gst/Makefile.am:
|
* docs/gst/Makefile.am:
|
||||||
|
|
|
@ -51,6 +51,7 @@ TESTS = $(top_builddir)/tools/gst-register \
|
||||||
pipelines/simple_launch_lines \
|
pipelines/simple_launch_lines \
|
||||||
pipelines/cleanup \
|
pipelines/cleanup \
|
||||||
states/sinks \
|
states/sinks \
|
||||||
|
gst-libs/controller \
|
||||||
gst-libs/gdp
|
gst-libs/gdp
|
||||||
|
|
||||||
check_PROGRAMS = $(TESTS)
|
check_PROGRAMS = $(TESTS)
|
||||||
|
@ -70,6 +71,9 @@ gst_libs_gdp_SOURCES = \
|
||||||
# remove GST_ENABLE_NEW when dataprotocol has been declared API-stable
|
# remove GST_ENABLE_NEW when dataprotocol has been declared API-stable
|
||||||
gst_libs_gdp_CFLAGS = $(AM_CFLAGS) -DGST_ENABLE_NEW
|
gst_libs_gdp_CFLAGS = $(AM_CFLAGS) -DGST_ENABLE_NEW
|
||||||
|
|
||||||
|
gst_libs_controller_LDADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) libgstcheck.la \
|
||||||
|
$(top_srcdir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
# valgrind testing
|
# valgrind testing
|
||||||
|
|
||||||
# these just need fixing, period
|
# these just need fixing, period
|
||||||
|
|
238
check/gst-libs/controller.c
Normal file
238
check/gst-libs/controller.c
Normal file
|
@ -0,0 +1,238 @@
|
||||||
|
/* GStreamer
|
||||||
|
*
|
||||||
|
* unit test for the controller library
|
||||||
|
*
|
||||||
|
* Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dor net>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "../gstcheck.h"
|
||||||
|
#include <gst/controller/gst-controller.h>
|
||||||
|
|
||||||
|
/* LOCAL TEST ELEMENT */
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ARG_ULONG = 1,
|
||||||
|
ARG_DOUBLE,
|
||||||
|
ARG_SWITCH,
|
||||||
|
ARG_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GST_TYPE_TEST_MONO_SOURCE (gst_test_mono_source_get_type ())
|
||||||
|
#define GST_TEST_MONO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSource))
|
||||||
|
#define GST_TEST_MONO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSourceClass))
|
||||||
|
#define GST_IS_TEST_MONO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TEST_MONO_SOURCE))
|
||||||
|
#define GST_IS_TEST_MONO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TEST_MONO_SOURCE))
|
||||||
|
#define GST_TEST_MONO_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSourceClass))
|
||||||
|
|
||||||
|
typedef struct _GstTestMonoSource GstTestMonoSource;
|
||||||
|
typedef struct _GstTestMonoSourceClass GstTestMonoSourceClass;
|
||||||
|
|
||||||
|
struct _GstTestMonoSource
|
||||||
|
{
|
||||||
|
GstElement parent;
|
||||||
|
};
|
||||||
|
struct _GstTestMonoSourceClass
|
||||||
|
{
|
||||||
|
GstElementClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_test_mono_source_get_type (void);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_get_property (GObject * object,
|
||||||
|
guint property_id, GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
//GstTestMonoSource *self = GST_TEST_MONO_SOURCE(object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
case ARG_ULONG:
|
||||||
|
break;
|
||||||
|
default:{
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_set_property (GObject * object,
|
||||||
|
guint property_id, const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
//GstTestMonoSource *self = GST_TEST_MONO_SOURCE(object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
case ARG_ULONG:
|
||||||
|
break;
|
||||||
|
default:{
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_class_init (GstTestMonoSourceClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->set_property = gst_test_mono_source_set_property;
|
||||||
|
gobject_class->get_property = gst_test_mono_source_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, ARG_ULONG,
|
||||||
|
g_param_spec_ulong ("ulong",
|
||||||
|
"ulong prop",
|
||||||
|
"ulong number parameter for the test_mono_source",
|
||||||
|
0, G_MAXULONG, 0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_base_init (GstTestMonoSourceClass * klass)
|
||||||
|
{
|
||||||
|
static const GstElementDetails details = {
|
||||||
|
"Monophonic source for unit tests",
|
||||||
|
"Source/Audio/MonoSource",
|
||||||
|
"Use in unit tests",
|
||||||
|
"Stefan Kost <ensonic@users.sf.net>"
|
||||||
|
};
|
||||||
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
|
gst_element_class_set_details (element_class, &details);
|
||||||
|
}
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_test_mono_source_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
static const GTypeInfo info = {
|
||||||
|
(guint16) sizeof (GstTestMonoSourceClass),
|
||||||
|
(GBaseInitFunc) gst_test_mono_source_base_init, // base_init
|
||||||
|
NULL, // base_finalize
|
||||||
|
(GClassInitFunc) gst_test_mono_source_class_init, // class_init
|
||||||
|
NULL, // class_finalize
|
||||||
|
NULL, // class_data
|
||||||
|
(guint16) sizeof (GstTestMonoSource),
|
||||||
|
0, // n_preallocs
|
||||||
|
NULL, // instance_init
|
||||||
|
NULL // value_table
|
||||||
|
};
|
||||||
|
type =
|
||||||
|
g_type_register_static (GST_TYPE_ELEMENT, "GstTestMonoSource", &info,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_test_plugin_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
gst_element_register (plugin, "testmonosource", GST_RANK_NONE,
|
||||||
|
GST_TYPE_TEST_MONO_SOURCE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
|
||||||
|
GST_VERSION_MINOR,
|
||||||
|
"gst-test",
|
||||||
|
"controller test plugin - several unit test support elements",
|
||||||
|
gst_test_plugin_init, VERSION, "LGPL", PACKAGE_NAME,
|
||||||
|
"http://gstreamer.freedesktop.org")
|
||||||
|
|
||||||
|
/* TESTS */
|
||||||
|
/* double init should not harm */
|
||||||
|
GST_START_TEST (controller_init)
|
||||||
|
{
|
||||||
|
gst_controller_init (NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST
|
||||||
|
/* tests for an element with no controlled params */
|
||||||
|
GST_START_TEST (controller_new_fail)
|
||||||
|
{
|
||||||
|
GstController *ctrl;
|
||||||
|
GstElement *elem;
|
||||||
|
|
||||||
|
elem = gst_element_factory_make ("fakesrc", "test_source");
|
||||||
|
|
||||||
|
/* that property should not exists */
|
||||||
|
ctrl = gst_controller_new (G_OBJECT (elem), "_schrompf_", NULL);
|
||||||
|
fail_unless (ctrl == NULL, NULL);
|
||||||
|
|
||||||
|
/* that property exists, but is not controllable */
|
||||||
|
ASSERT_CRITICAL (ctrl = gst_controller_new (G_OBJECT (elem), "name", NULL));
|
||||||
|
fail_unless (ctrl == NULL, NULL);
|
||||||
|
|
||||||
|
g_object_unref (elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST
|
||||||
|
/* tests for an element with controlled params */
|
||||||
|
GST_START_TEST (controller_new_okay)
|
||||||
|
{
|
||||||
|
GstController *ctrl;
|
||||||
|
GstElement *elem;
|
||||||
|
|
||||||
|
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||||
|
|
||||||
|
/* that property should exist and should be controllable */
|
||||||
|
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
|
||||||
|
fail_unless (ctrl != NULL, NULL);
|
||||||
|
|
||||||
|
g_object_unref (ctrl);
|
||||||
|
g_object_unref (elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST
|
||||||
|
/* @TODO write more tests (using an internal element that has controlable params)
|
||||||
|
*/
|
||||||
|
Suite * gst_controller_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("Controller");
|
||||||
|
TCase *tc = tcase_create ("general");
|
||||||
|
|
||||||
|
/* turn off timeout */
|
||||||
|
tcase_set_timeout (tc, 60);
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc);
|
||||||
|
tcase_add_test (tc, controller_init);
|
||||||
|
tcase_add_test (tc, controller_new_fail);
|
||||||
|
tcase_add_test (tc, controller_new_okay);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int nf;
|
||||||
|
|
||||||
|
Suite *s = gst_controller_suite ();
|
||||||
|
SRunner *sr = srunner_create (s);
|
||||||
|
|
||||||
|
gst_check_init (&argc, &argv);
|
||||||
|
gst_controller_init (NULL, NULL);
|
||||||
|
|
||||||
|
srunner_run_all (sr, CK_NORMAL);
|
||||||
|
nf = srunner_ntests_failed (sr);
|
||||||
|
srunner_free (sr);
|
||||||
|
|
||||||
|
return nf;
|
||||||
|
}
|
|
@ -23,7 +23,7 @@
|
||||||
/**
|
/**
|
||||||
* SECTION:gstpushsrc
|
* SECTION:gstpushsrc
|
||||||
* @short_description: Base class for push based source elements
|
* @short_description: Base class for push based source elements
|
||||||
* @see_also: #GstBaseTransformc, #GstBaseSink
|
* @see_also: #GstBaseSrc
|
||||||
*
|
*
|
||||||
* This class is mostly usefull for elements that cannot do
|
* This class is mostly usefull for elements that cannot do
|
||||||
* random access, or at least very slowly. The source usually
|
* random access, or at least very slowly. The source usually
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
/**
|
/**
|
||||||
* SECTION:gstpushsrc
|
* SECTION:gstpushsrc
|
||||||
* @short_description: Base class for push based source elements
|
* @short_description: Base class for push based source elements
|
||||||
* @see_also: #GstBaseTransformc, #GstBaseSink
|
* @see_also: #GstBaseSrc
|
||||||
*
|
*
|
||||||
* This class is mostly usefull for elements that cannot do
|
* This class is mostly usefull for elements that cannot do
|
||||||
* random access, or at least very slowly. The source usually
|
* random access, or at least very slowly. The source usually
|
||||||
|
|
|
@ -48,7 +48,7 @@ GQuark controller_key;
|
||||||
/* imports from gst-interpolation.c */
|
/* imports from gst-interpolation.c */
|
||||||
|
|
||||||
extern GList
|
extern GList
|
||||||
*gst_controlled_property_find_timed_value_node (GstControlledProperty *
|
* gst_controlled_property_find_timed_value_node (GstControlledProperty *
|
||||||
prop, GstClockTime timestamp);
|
prop, GstClockTime timestamp);
|
||||||
extern GstInterpolateMethod *interpolation_methods[];
|
extern GstInterpolateMethod *interpolation_methods[];
|
||||||
|
|
||||||
|
@ -368,17 +368,19 @@ gst_controller_new_valist (GObject * object, va_list var_args)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
self = g_object_get_qdata (object, controller_key);
|
self = g_object_get_qdata (object, controller_key);
|
||||||
if (!self) {
|
|
||||||
self = g_object_new (GST_TYPE_CONTROLLER, NULL);
|
|
||||||
self->lock = g_mutex_new ();
|
|
||||||
// store the controller
|
|
||||||
g_object_set_qdata (object, controller_key, self);
|
|
||||||
}
|
|
||||||
// create GstControlledProperty for each property
|
// create GstControlledProperty for each property
|
||||||
while ((name = va_arg (var_args, gchar *))) {
|
while ((name = va_arg (var_args, gchar *))) {
|
||||||
// create GstControlledProperty and add to self->propeties List
|
// create GstControlledProperty and add to self->propeties List
|
||||||
if ((prop = gst_controlled_property_new (object, name)))
|
if ((prop = gst_controlled_property_new (object, name))) {
|
||||||
|
// if we don't have a controller object yet, now is the time to create one
|
||||||
|
if (!self) {
|
||||||
|
self = g_object_new (GST_TYPE_CONTROLLER, NULL);
|
||||||
|
self->lock = g_mutex_new ();
|
||||||
|
// store the controller
|
||||||
|
g_object_set_qdata (object, controller_key, self);
|
||||||
|
}
|
||||||
self->properties = g_list_prepend (self->properties, prop);
|
self->properties = g_list_prepend (self->properties, prop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
va_end (var_args);
|
va_end (var_args);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ GQuark controller_key;
|
||||||
/* imports from gst-interpolation.c */
|
/* imports from gst-interpolation.c */
|
||||||
|
|
||||||
extern GList
|
extern GList
|
||||||
*gst_controlled_property_find_timed_value_node (GstControlledProperty *
|
* gst_controlled_property_find_timed_value_node (GstControlledProperty *
|
||||||
prop, GstClockTime timestamp);
|
prop, GstClockTime timestamp);
|
||||||
extern GstInterpolateMethod *interpolation_methods[];
|
extern GstInterpolateMethod *interpolation_methods[];
|
||||||
|
|
||||||
|
@ -368,17 +368,19 @@ gst_controller_new_valist (GObject * object, va_list var_args)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
self = g_object_get_qdata (object, controller_key);
|
self = g_object_get_qdata (object, controller_key);
|
||||||
if (!self) {
|
|
||||||
self = g_object_new (GST_TYPE_CONTROLLER, NULL);
|
|
||||||
self->lock = g_mutex_new ();
|
|
||||||
// store the controller
|
|
||||||
g_object_set_qdata (object, controller_key, self);
|
|
||||||
}
|
|
||||||
// create GstControlledProperty for each property
|
// create GstControlledProperty for each property
|
||||||
while ((name = va_arg (var_args, gchar *))) {
|
while ((name = va_arg (var_args, gchar *))) {
|
||||||
// create GstControlledProperty and add to self->propeties List
|
// create GstControlledProperty and add to self->propeties List
|
||||||
if ((prop = gst_controlled_property_new (object, name)))
|
if ((prop = gst_controlled_property_new (object, name))) {
|
||||||
|
// if we don't have a controller object yet, now is the time to create one
|
||||||
|
if (!self) {
|
||||||
|
self = g_object_new (GST_TYPE_CONTROLLER, NULL);
|
||||||
|
self->lock = g_mutex_new ();
|
||||||
|
// store the controller
|
||||||
|
g_object_set_qdata (object, controller_key, self);
|
||||||
|
}
|
||||||
self->properties = g_list_prepend (self->properties, prop);
|
self->properties = g_list_prepend (self->properties, prop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
va_end (var_args);
|
va_end (var_args);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ TESTS = $(top_builddir)/tools/gst-register \
|
||||||
pipelines/simple_launch_lines \
|
pipelines/simple_launch_lines \
|
||||||
pipelines/cleanup \
|
pipelines/cleanup \
|
||||||
states/sinks \
|
states/sinks \
|
||||||
|
gst-libs/controller \
|
||||||
gst-libs/gdp
|
gst-libs/gdp
|
||||||
|
|
||||||
check_PROGRAMS = $(TESTS)
|
check_PROGRAMS = $(TESTS)
|
||||||
|
@ -70,6 +71,9 @@ gst_libs_gdp_SOURCES = \
|
||||||
# remove GST_ENABLE_NEW when dataprotocol has been declared API-stable
|
# remove GST_ENABLE_NEW when dataprotocol has been declared API-stable
|
||||||
gst_libs_gdp_CFLAGS = $(AM_CFLAGS) -DGST_ENABLE_NEW
|
gst_libs_gdp_CFLAGS = $(AM_CFLAGS) -DGST_ENABLE_NEW
|
||||||
|
|
||||||
|
gst_libs_controller_LDADD = $(GST_OBJ_LIBS) $(CHECK_LIBS) libgstcheck.la \
|
||||||
|
$(top_srcdir)/libs/gst/controller/libgstcontroller-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
# valgrind testing
|
# valgrind testing
|
||||||
|
|
||||||
# these just need fixing, period
|
# these just need fixing, period
|
||||||
|
|
238
tests/check/libs/controller.c
Normal file
238
tests/check/libs/controller.c
Normal file
|
@ -0,0 +1,238 @@
|
||||||
|
/* GStreamer
|
||||||
|
*
|
||||||
|
* unit test for the controller library
|
||||||
|
*
|
||||||
|
* Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dor net>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 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
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "../gstcheck.h"
|
||||||
|
#include <gst/controller/gst-controller.h>
|
||||||
|
|
||||||
|
/* LOCAL TEST ELEMENT */
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ARG_ULONG = 1,
|
||||||
|
ARG_DOUBLE,
|
||||||
|
ARG_SWITCH,
|
||||||
|
ARG_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GST_TYPE_TEST_MONO_SOURCE (gst_test_mono_source_get_type ())
|
||||||
|
#define GST_TEST_MONO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSource))
|
||||||
|
#define GST_TEST_MONO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSourceClass))
|
||||||
|
#define GST_IS_TEST_MONO_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TEST_MONO_SOURCE))
|
||||||
|
#define GST_IS_TEST_MONO_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TEST_MONO_SOURCE))
|
||||||
|
#define GST_TEST_MONO_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TEST_MONO_SOURCE, GstTestMonoSourceClass))
|
||||||
|
|
||||||
|
typedef struct _GstTestMonoSource GstTestMonoSource;
|
||||||
|
typedef struct _GstTestMonoSourceClass GstTestMonoSourceClass;
|
||||||
|
|
||||||
|
struct _GstTestMonoSource
|
||||||
|
{
|
||||||
|
GstElement parent;
|
||||||
|
};
|
||||||
|
struct _GstTestMonoSourceClass
|
||||||
|
{
|
||||||
|
GstElementClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_test_mono_source_get_type (void);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_get_property (GObject * object,
|
||||||
|
guint property_id, GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
//GstTestMonoSource *self = GST_TEST_MONO_SOURCE(object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
case ARG_ULONG:
|
||||||
|
break;
|
||||||
|
default:{
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_set_property (GObject * object,
|
||||||
|
guint property_id, const GValue * value, GParamSpec * pspec)
|
||||||
|
{
|
||||||
|
//GstTestMonoSource *self = GST_TEST_MONO_SOURCE(object);
|
||||||
|
|
||||||
|
switch (property_id) {
|
||||||
|
case ARG_ULONG:
|
||||||
|
break;
|
||||||
|
default:{
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_class_init (GstTestMonoSourceClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->set_property = gst_test_mono_source_set_property;
|
||||||
|
gobject_class->get_property = gst_test_mono_source_get_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, ARG_ULONG,
|
||||||
|
g_param_spec_ulong ("ulong",
|
||||||
|
"ulong prop",
|
||||||
|
"ulong number parameter for the test_mono_source",
|
||||||
|
0, G_MAXULONG, 0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_test_mono_source_base_init (GstTestMonoSourceClass * klass)
|
||||||
|
{
|
||||||
|
static const GstElementDetails details = {
|
||||||
|
"Monophonic source for unit tests",
|
||||||
|
"Source/Audio/MonoSource",
|
||||||
|
"Use in unit tests",
|
||||||
|
"Stefan Kost <ensonic@users.sf.net>"
|
||||||
|
};
|
||||||
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
|
||||||
|
gst_element_class_set_details (element_class, &details);
|
||||||
|
}
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_test_mono_source_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
|
||||||
|
if (type == 0) {
|
||||||
|
static const GTypeInfo info = {
|
||||||
|
(guint16) sizeof (GstTestMonoSourceClass),
|
||||||
|
(GBaseInitFunc) gst_test_mono_source_base_init, // base_init
|
||||||
|
NULL, // base_finalize
|
||||||
|
(GClassInitFunc) gst_test_mono_source_class_init, // class_init
|
||||||
|
NULL, // class_finalize
|
||||||
|
NULL, // class_data
|
||||||
|
(guint16) sizeof (GstTestMonoSource),
|
||||||
|
0, // n_preallocs
|
||||||
|
NULL, // instance_init
|
||||||
|
NULL // value_table
|
||||||
|
};
|
||||||
|
type =
|
||||||
|
g_type_register_static (GST_TYPE_ELEMENT, "GstTestMonoSource", &info,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_test_plugin_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
gst_element_register (plugin, "testmonosource", GST_RANK_NONE,
|
||||||
|
GST_TYPE_TEST_MONO_SOURCE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR,
|
||||||
|
GST_VERSION_MINOR,
|
||||||
|
"gst-test",
|
||||||
|
"controller test plugin - several unit test support elements",
|
||||||
|
gst_test_plugin_init, VERSION, "LGPL", PACKAGE_NAME,
|
||||||
|
"http://gstreamer.freedesktop.org")
|
||||||
|
|
||||||
|
/* TESTS */
|
||||||
|
/* double init should not harm */
|
||||||
|
GST_START_TEST (controller_init)
|
||||||
|
{
|
||||||
|
gst_controller_init (NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST
|
||||||
|
/* tests for an element with no controlled params */
|
||||||
|
GST_START_TEST (controller_new_fail)
|
||||||
|
{
|
||||||
|
GstController *ctrl;
|
||||||
|
GstElement *elem;
|
||||||
|
|
||||||
|
elem = gst_element_factory_make ("fakesrc", "test_source");
|
||||||
|
|
||||||
|
/* that property should not exists */
|
||||||
|
ctrl = gst_controller_new (G_OBJECT (elem), "_schrompf_", NULL);
|
||||||
|
fail_unless (ctrl == NULL, NULL);
|
||||||
|
|
||||||
|
/* that property exists, but is not controllable */
|
||||||
|
ASSERT_CRITICAL (ctrl = gst_controller_new (G_OBJECT (elem), "name", NULL));
|
||||||
|
fail_unless (ctrl == NULL, NULL);
|
||||||
|
|
||||||
|
g_object_unref (elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST
|
||||||
|
/* tests for an element with controlled params */
|
||||||
|
GST_START_TEST (controller_new_okay)
|
||||||
|
{
|
||||||
|
GstController *ctrl;
|
||||||
|
GstElement *elem;
|
||||||
|
|
||||||
|
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||||
|
|
||||||
|
/* that property should exist and should be controllable */
|
||||||
|
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
|
||||||
|
fail_unless (ctrl != NULL, NULL);
|
||||||
|
|
||||||
|
g_object_unref (ctrl);
|
||||||
|
g_object_unref (elem);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST
|
||||||
|
/* @TODO write more tests (using an internal element that has controlable params)
|
||||||
|
*/
|
||||||
|
Suite * gst_controller_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("Controller");
|
||||||
|
TCase *tc = tcase_create ("general");
|
||||||
|
|
||||||
|
/* turn off timeout */
|
||||||
|
tcase_set_timeout (tc, 60);
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc);
|
||||||
|
tcase_add_test (tc, controller_init);
|
||||||
|
tcase_add_test (tc, controller_new_fail);
|
||||||
|
tcase_add_test (tc, controller_new_okay);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int nf;
|
||||||
|
|
||||||
|
Suite *s = gst_controller_suite ();
|
||||||
|
SRunner *sr = srunner_create (s);
|
||||||
|
|
||||||
|
gst_check_init (&argc, &argv);
|
||||||
|
gst_controller_init (NULL, NULL);
|
||||||
|
|
||||||
|
srunner_run_all (sr, CK_NORMAL);
|
||||||
|
nf = srunner_ntests_failed (sr);
|
||||||
|
srunner_free (sr);
|
||||||
|
|
||||||
|
return nf;
|
||||||
|
}
|
Loading…
Reference in a new issue