controller: fix tests after move and API changes

This commit is contained in:
Stefan Sauer 2011-11-04 14:00:24 +01:00
parent b5d35e2acb
commit dfd7ea1628
2 changed files with 73 additions and 277 deletions

View file

@ -26,8 +26,6 @@
#endif #endif
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include <gst/controller/gstcontroller.h>
#include <gst/controller/gstcontrolsource.h>
#include <gst/controller/gstinterpolationcontrolsource.h> #include <gst/controller/gstinterpolationcontrolsource.h>
#include <gst/controller/gstlfocontrolsource.h> #include <gst/controller/gstlfocontrolsource.h>
@ -215,124 +213,98 @@ gst_test_mono_source_get_type (void)
return test_mono_source_type; return test_mono_source_type;
} }
/* so we don't have to paste the gst_element_register into 50 places below */ static void
static gboolean setup (void)
local_gst_controller_init (int *argc, char ***argv) {
gst_element_register (NULL, "testmonosource", GST_RANK_NONE,
GST_TYPE_TEST_MONO_SOURCE);
}
static void
teardown (void)
{ {
fail_unless (gst_controller_init (argc, argv));
fail_unless (gst_element_register (NULL, "testmonosource", GST_RANK_NONE,
GST_TYPE_TEST_MONO_SOURCE));
return TRUE;
} }
#define gst_controller_init(a,b) local_gst_controller_init(a,b)
/* TESTS */ /* TESTS */
/* double init should not harm */
GST_START_TEST (controller_init)
{
gst_controller_init (NULL, NULL);
gst_controller_init (NULL, NULL);
gst_controller_init (NULL, NULL);
gst_controller_init (NULL, NULL);
}
GST_END_TEST;
/* tests for an element with no controlled params */ /* tests for an element with no controlled params */
GST_START_TEST (controller_new_fail1) GST_START_TEST (controller_new_fail1)
{ {
GstController *ctrl; GstController *ctrl;
GstElement *elem; GstElement *elem;
gboolean res;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("fakesrc", "test_source"); elem = gst_element_factory_make ("fakesrc", "test_source");
ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
/* that property should not exist */ /* that property should not exist */
ctrl = gst_controller_new (G_OBJECT (elem), "_schrompf_", NULL); res = gst_controller_add_properties (ctrl, "_schrompf_", NULL);
fail_unless (ctrl == NULL, NULL); fail_unless (res == FALSE, NULL);
gst_object_unref (elem);
}
GST_END_TEST;
/* tests for an element with controlled params, but none given */
GST_START_TEST (controller_new_fail2)
{
GstController *ctrl;
GstElement *elem;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source");
/* no property given */
ctrl = gst_controller_new (G_OBJECT (elem), NULL);
fail_unless (ctrl == NULL, NULL);
g_object_unref (ctrl);
gst_object_unref (elem); gst_object_unref (elem);
} }
GST_END_TEST; GST_END_TEST;
/* tests for readonly params */ /* tests for readonly params */
GST_START_TEST (controller_new_fail3) GST_START_TEST (controller_new_fail2)
{ {
GstController *ctrl; GstController *ctrl;
GstElement *elem; GstElement *elem;
gboolean res;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
/* that property should exist and but is readonly */ /* that property should exist and but is readonly */
ASSERT_CRITICAL (ctrl = ASSERT_CRITICAL (res =
gst_controller_new (G_OBJECT (elem), "readonly", NULL)); gst_controller_add_properties (ctrl, "readonly", NULL));
fail_unless (ctrl == NULL, NULL); fail_unless (res == FALSE, NULL);
g_object_unref (ctrl);
gst_object_unref (elem); gst_object_unref (elem);
} }
GST_END_TEST; GST_END_TEST;
/* tests for static params */ /* tests for static params */
GST_START_TEST (controller_new_fail4) GST_START_TEST (controller_new_fail3)
{ {
GstController *ctrl; GstController *ctrl;
GstElement *elem; GstElement *elem;
gboolean res;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
/* that property should exist and but is not controlable */ /* that property should exist and but is not controlable */
ASSERT_CRITICAL (ctrl = gst_controller_new (G_OBJECT (elem), "static", NULL)); ASSERT_CRITICAL (res = gst_controller_add_properties (ctrl, "static", NULL));
fail_unless (ctrl == NULL, NULL); fail_unless (res == FALSE, NULL);
g_object_unref (ctrl);
gst_object_unref (elem); gst_object_unref (elem);
} }
GST_END_TEST; GST_END_TEST;
/* tests for construct-only params */ /* tests for construct-only params */
GST_START_TEST (controller_new_fail5) GST_START_TEST (controller_new_fail4)
{ {
GstController *ctrl; GstController *ctrl;
GstElement *elem; GstElement *elem;
gboolean res;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
ctrl = gst_controller_new (GST_OBJECT (elem), NULL);
/* that property should exist and but is construct-only */ /* that property should exist and but is construct-only */
ASSERT_CRITICAL (ctrl = ASSERT_CRITICAL (res =
gst_controller_new (G_OBJECT (elem), "construct-only", NULL)); gst_controller_add_properties (ctrl, "construct-only", NULL));
fail_unless (ctrl == NULL, NULL); fail_unless (res == FALSE, NULL);
g_object_unref (ctrl);
gst_object_unref (elem); gst_object_unref (elem);
} }
@ -345,12 +317,10 @@ GST_START_TEST (controller_new_okay1)
GstController *ctrl; GstController *ctrl;
GstElement *elem; GstElement *elem;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
@ -363,74 +333,24 @@ GST_END_TEST;
/* tests for an element with several controlled params */ /* tests for an element with several controlled params */
GST_START_TEST (controller_new_okay2) GST_START_TEST (controller_new_okay2)
{ {
GstController *ctrl, *ctrl2, *ctrl3; GstController *ctrl;
GstElement *elem; GstElement *elem;
gboolean res;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "double", "float", NULL); ctrl =
gst_controller_new (GST_OBJECT (elem), "ulong", "double", "float", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1); fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
ctrl2 = gst_controller_new (G_OBJECT (elem), "boolean", NULL); res = gst_controller_add_properties (ctrl, "boolean", NULL);
fail_unless (ctrl2 != NULL, NULL); fail_unless (res == TRUE, NULL);
fail_unless (ctrl2 == ctrl, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
/* trying to control the same properties again should correctly
* increase the refcount of the object returned as well */
ctrl3 =
gst_controller_new (G_OBJECT (elem), "ulong", "double", "float", NULL);
fail_unless (ctrl3 != NULL, NULL);
fail_unless (ctrl3 == ctrl, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 3);
g_object_unref (ctrl); g_object_unref (ctrl);
g_object_unref (ctrl2);
g_object_unref (ctrl3);
gst_object_unref (elem);
}
GST_END_TEST;
/* controlling several params should return the same controller */
GST_START_TEST (controller_new_okay3)
{
GstController *ctrl1, *ctrl2, *ctrl3;
GstElement *elem;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */
ctrl1 = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl1 != NULL, NULL);
/* that property should exist and should be controllable */
ctrl2 = gst_controller_new (G_OBJECT (elem), "double", NULL);
fail_unless (ctrl2 != NULL, NULL);
fail_unless (ctrl1 == ctrl2, NULL);
/* that property should exist and should be controllable */
ctrl3 = gst_controller_new (G_OBJECT (elem), "float", NULL);
fail_unless (ctrl3 != NULL, NULL);
fail_unless (ctrl1 == ctrl3, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl1)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl1)->ref_count, 3);
g_object_unref (ctrl1);
g_object_unref (ctrl2);
g_object_unref (ctrl3);
gst_object_unref (elem); gst_object_unref (elem);
} }
@ -443,12 +363,10 @@ GST_START_TEST (controller_param_twice)
GstElement *elem; GstElement *elem;
gboolean res; gboolean res;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* it should have been added at least once, let remove it */ /* it should have been added at least once, let remove it */
@ -466,32 +384,6 @@ GST_START_TEST (controller_param_twice)
GST_END_TEST; GST_END_TEST;
/* tests if we cleanup properly */
GST_START_TEST (controller_finalize)
{
GstController *ctrl;
GstElement *elem;
gst_controller_init (NULL, NULL);
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);
/* free the controller */
g_object_unref (ctrl);
/* object shouldn't have a controller anymore */
ctrl = gst_object_get_controller (G_OBJECT (elem));
fail_unless (ctrl == NULL, NULL);
gst_object_unref (elem);
}
GST_END_TEST;
/* tests if we cleanup properly */ /* tests if we cleanup properly */
GST_START_TEST (controller_controlsource_refcounts) GST_START_TEST (controller_controlsource_refcounts)
{ {
@ -499,12 +391,10 @@ GST_START_TEST (controller_controlsource_refcounts)
GstElement *elem; GstElement *elem;
GstControlSource *csource, *test_csource; GstControlSource *csource, *test_csource;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
csource = (GstControlSource *) gst_interpolation_control_source_new (); csource = (GstControlSource *) gst_interpolation_control_source_new ();
@ -525,10 +415,6 @@ GST_START_TEST (controller_controlsource_refcounts)
/* free the controller */ /* free the controller */
g_object_unref (ctrl); g_object_unref (ctrl);
/* object shouldn't have a controller anymore */
ctrl = gst_object_get_controller (G_OBJECT (elem));
fail_unless (ctrl == NULL, NULL);
gst_object_unref (elem); gst_object_unref (elem);
} }
@ -541,12 +427,10 @@ GST_START_TEST (controller_controlsource_empty1)
GstElement *elem; GstElement *elem;
GstControlSource *csource; GstControlSource *csource;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
csource = (GstControlSource *) gst_interpolation_control_source_new (); csource = (GstControlSource *) gst_interpolation_control_source_new ();
@ -573,12 +457,10 @@ GST_START_TEST (controller_controlsource_empty2)
GstInterpolationControlSource *csource; GstInterpolationControlSource *csource;
GValue val = { 0, }; GValue val = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
csource = gst_interpolation_control_source_new (); csource = gst_interpolation_control_source_new ();
@ -615,12 +497,10 @@ GST_START_TEST (controller_interpolate_none)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -677,12 +557,10 @@ GST_START_TEST (controller_interpolate_trigger)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -744,12 +622,10 @@ GST_START_TEST (controller_interpolate_linear)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -802,12 +678,10 @@ GST_START_TEST (controller_interpolate_cubic)
gboolean res; gboolean res;
GValue val_double = { 0, }; GValue val_double = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "double", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "double", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -877,12 +751,10 @@ GST_START_TEST (controller_interpolate_cubic_too_few_cp)
gboolean res; gboolean res;
GValue val_double = { 0, }; GValue val_double = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "double", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "double", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -936,12 +808,10 @@ GST_START_TEST (controller_interpolate_unimplemented)
GstInterpolationControlSource *csource; GstInterpolationControlSource *csource;
GstElement *elem; GstElement *elem;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -972,12 +842,10 @@ GST_START_TEST (controller_interpolation_unset)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1053,12 +921,10 @@ GST_START_TEST (controller_interpolation_unset_all)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1117,12 +983,10 @@ GST_START_TEST (controller_interpolation_linear_value_array)
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
GstValueArray values = { NULL, }; GstValueArray values = { NULL, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1180,12 +1044,10 @@ GST_START_TEST (controller_interpolation_linear_invalid_values)
gboolean res; gboolean res;
GValue val_float = { 0, }; GValue val_float = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "float", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "float", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1249,12 +1111,10 @@ GST_START_TEST (controller_interpolation_linear_default_values)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1347,12 +1207,10 @@ GST_START_TEST (controller_interpolate_linear_disabled)
, val_double = { , val_double = {
0,}; 0,};
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", "double", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", "double", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1499,13 +1357,11 @@ GST_START_TEST (controller_interpolation_set_from_list)
GstElement *elem; GstElement *elem;
GSList *list = NULL; GSList *list = NULL;
gst_controller_init (NULL, NULL);
/* test that an invalid timestamp throws a warning of some sort */ /* test that an invalid timestamp throws a warning of some sort */
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1555,12 +1411,10 @@ GST_START_TEST (controller_lfo_sine)
, off = { , off = {
0,}; 0,};
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1626,12 +1480,10 @@ GST_START_TEST (controller_lfo_sine_timeshift)
, off = { , off = {
0,}; 0,};
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1697,12 +1549,10 @@ GST_START_TEST (controller_lfo_square)
, off = { , off = {
0,}; 0,};
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1768,12 +1618,10 @@ GST_START_TEST (controller_lfo_saw)
, off = { , off = {
0,}; 0,};
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1839,12 +1687,10 @@ GST_START_TEST (controller_lfo_rsaw)
, off = { , off = {
0,}; 0,};
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1910,12 +1756,10 @@ GST_START_TEST (controller_lfo_triangle)
, off = { , off = {
0,}; 0,};
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -1978,12 +1822,10 @@ GST_START_TEST (controller_lfo_none)
GstLFOControlSource *csource; GstLFOControlSource *csource;
GstElement *elem; GstElement *elem;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -2034,12 +1876,10 @@ GST_START_TEST (controller_helper_any_gobject)
GstElement *elem; GstElement *elem;
gboolean res; gboolean res;
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("bin", "test_elem"); elem = gst_element_factory_make ("bin", "test_elem");
/* that element is not controllable */ /* that element is not controllable */
res = gst_object_sync_values (G_OBJECT (elem), 0LL); res = gst_object_sync_values (GST_OBJECT (elem), 0LL);
/* Syncing should still succeed as there's nothing to sync */ /* Syncing should still succeed as there's nothing to sync */
fail_unless (res == TRUE, NULL); fail_unless (res == TRUE, NULL);
@ -2050,16 +1890,14 @@ GST_END_TEST;
GST_START_TEST (controller_refcount_new_list) GST_START_TEST (controller_refcount_new_list)
{ {
GstController *ctrl, *ctrl2; GstController *ctrl;
GstElement *elem; GstElement *elem;
GList *list = NULL; GList *list = NULL;
gst_controller_init (NULL, NULL);
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
list = g_list_append (NULL, (char *) "ulong"); list = g_list_append (NULL, (char *) "ulong");
ctrl = gst_controller_new_list (G_OBJECT (elem), list); ctrl = gst_controller_new_list (GST_OBJECT (elem), list);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1); fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
@ -2071,7 +1909,7 @@ GST_START_TEST (controller_refcount_new_list)
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
list = g_list_append (NULL, (char *) "ulong"); list = g_list_append (NULL, (char *) "ulong");
list = g_list_append (list, (char *) "ulong"); list = g_list_append (list, (char *) "ulong");
ctrl = gst_controller_new_list (G_OBJECT (elem), list); ctrl = gst_controller_new_list (GST_OBJECT (elem), list);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1); fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
@ -2083,45 +1921,13 @@ GST_START_TEST (controller_refcount_new_list)
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
list = g_list_append (NULL, (char *) "ulong"); list = g_list_append (NULL, (char *) "ulong");
list = g_list_append (list, (char *) "boolean"); list = g_list_append (list, (char *) "boolean");
ctrl = gst_controller_new_list (G_OBJECT (elem), list); ctrl = gst_controller_new_list (GST_OBJECT (elem), list);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count); GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1); fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 1);
g_list_free (list); g_list_free (list);
g_object_unref (ctrl); g_object_unref (ctrl);
gst_object_unref (elem); gst_object_unref (elem);
/* try _new_list with existing controller */
elem = gst_element_factory_make ("testmonosource", "test_source");
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
list = g_list_append (NULL, (char *) "ulong");
ctrl2 = gst_controller_new_list (G_OBJECT (elem), list);
fail_unless (ctrl2 != NULL, NULL);
fail_unless (ctrl == ctrl2, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
g_list_free (list);
g_object_unref (ctrl);
g_object_unref (ctrl2);
gst_object_unref (elem);
/* try _new_list first and then _new */
elem = gst_element_factory_make ("testmonosource", "test_source");
list = g_list_append (NULL, (char *) "ulong");
ctrl = gst_controller_new_list (G_OBJECT (elem), list);
fail_unless (ctrl != NULL, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
ctrl2 = gst_controller_new (G_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl2 != NULL, NULL);
fail_unless (ctrl == ctrl2, NULL);
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
fail_unless_equals_int (G_OBJECT (ctrl)->ref_count, 2);
g_list_free (list);
g_object_unref (ctrl);
g_object_unref (ctrl2);
gst_object_unref (elem);
} }
GST_END_TEST; GST_END_TEST;
@ -2135,12 +1941,10 @@ GST_START_TEST (controller_interpolate_linear_before_ts0)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -2199,12 +2003,10 @@ GST_START_TEST (controller_interpolation_cp_count)
gboolean res; gboolean res;
GValue val_ulong = { 0, }; GValue val_ulong = { 0, };
gst_controller_init (NULL, NULL);
elem = gst_element_factory_make ("testmonosource", "test_source"); elem = gst_element_factory_make ("testmonosource", "test_source");
/* that property should exist and should be controllable */ /* that property should exist and should be controllable */
ctrl = gst_controller_new (G_OBJECT (elem), "ulong", NULL); ctrl = gst_controller_new (GST_OBJECT (elem), "ulong", NULL);
fail_unless (ctrl != NULL, NULL); fail_unless (ctrl != NULL, NULL);
/* Get interpolation control source */ /* Get interpolation control source */
@ -2261,18 +2063,15 @@ gst_controller_suite (void)
TCase *tc = tcase_create ("general"); TCase *tc = tcase_create ("general");
suite_add_tcase (s, tc); suite_add_tcase (s, tc);
tcase_add_test (tc, controller_init); tcase_add_checked_fixture (tc, setup, teardown);
tcase_add_test (tc, controller_refcount_new_list); tcase_add_test (tc, controller_refcount_new_list);
tcase_add_test (tc, controller_new_fail1); tcase_add_test (tc, controller_new_fail1);
tcase_add_test (tc, controller_new_fail2); tcase_add_test (tc, controller_new_fail2);
tcase_add_test (tc, controller_new_fail3); tcase_add_test (tc, controller_new_fail3);
tcase_add_test (tc, controller_new_fail4); tcase_add_test (tc, controller_new_fail4);
tcase_add_test (tc, controller_new_fail5);
tcase_add_test (tc, controller_new_okay1); tcase_add_test (tc, controller_new_okay1);
tcase_add_test (tc, controller_new_okay2); tcase_add_test (tc, controller_new_okay2);
tcase_add_test (tc, controller_new_okay3);
tcase_add_test (tc, controller_param_twice); tcase_add_test (tc, controller_param_twice);
tcase_add_test (tc, controller_finalize);
tcase_add_test (tc, controller_controlsource_refcounts); tcase_add_test (tc, controller_controlsource_refcounts);
tcase_add_test (tc, controller_controlsource_empty1); tcase_add_test (tc, controller_controlsource_empty1);
tcase_add_test (tc, controller_controlsource_empty2); tcase_add_test (tc, controller_controlsource_empty2);

View file

@ -35,9 +35,6 @@
#include <gst/base/gstpushsrc.h> #include <gst/base/gstpushsrc.h>
#include <gst/base/gsttypefindhelper.h> #include <gst/base/gsttypefindhelper.h>
#include <gst/controller/gstcontroller.h>
#include <gst/controller/gstcontrollerprivate.h>
#include <gst/controller/gstcontrolsource.h>
#include <gst/controller/gstinterpolationcontrolsource.h> #include <gst/controller/gstinterpolationcontrolsource.h>
#include <gst/controller/gstinterpolationcontrolsourceprivate.h> #include <gst/controller/gstinterpolationcontrolsourceprivate.h>
#include <gst/controller/gstlfocontrolsource.h> #include <gst/controller/gstlfocontrolsource.h>