mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
tests/check/libs/controller.c: Add test for the previous fix; add some more tests for correct refcounting behaviour; ...
Original commit message from CVS: * tests/check/libs/controller.c: (GST_START_TEST), (gst_controller_suite): Add test for the previous fix; add some more tests for correct refcounting behaviour; fix a few leaks in test cases; call gst_controller_init() at start of all tests.
This commit is contained in:
parent
3040ad0e2d
commit
c67ec73df6
2 changed files with 113 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
|||
2006-09-29 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* tests/check/libs/controller.c: (GST_START_TEST),
|
||||
(gst_controller_suite):
|
||||
Add test for the previous fix; add some more tests
|
||||
for correct refcounting behaviour; fix a few leaks
|
||||
in test cases; call gst_controller_init() at start
|
||||
of all tests.
|
||||
|
||||
2006-09-29 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* libs/gst/controller/gstcontroller.c: (gst_controller_new_valist),
|
||||
|
|
|
@ -249,6 +249,9 @@ _gst_plugin_static_init__plugin_init (void)
|
|||
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;
|
||||
|
@ -259,6 +262,8 @@ GST_START_TEST (controller_new_fail1)
|
|||
GstController *ctrl;
|
||||
GstElement *elem;
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("fakesrc", "test_source");
|
||||
|
||||
/* that property should not exist */
|
||||
|
@ -276,6 +281,8 @@ 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 */
|
||||
|
@ -293,6 +300,8 @@ GST_START_TEST (controller_new_fail3)
|
|||
GstController *ctrl;
|
||||
GstElement *elem;
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and but is readonly */
|
||||
|
@ -311,6 +320,8 @@ GST_START_TEST (controller_new_fail4)
|
|||
GstController *ctrl;
|
||||
GstElement *elem;
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and but is not controlable */
|
||||
|
@ -328,6 +339,8 @@ GST_START_TEST (controller_new_fail5)
|
|||
GstController *ctrl;
|
||||
GstElement *elem;
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and but is construct-only */
|
||||
|
@ -347,6 +360,8 @@ GST_START_TEST (controller_new_okay1)
|
|||
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 */
|
||||
|
@ -363,9 +378,11 @@ GST_END_TEST;
|
|||
/* tests for an element with several controlled params */
|
||||
GST_START_TEST (controller_new_okay2)
|
||||
{
|
||||
GstController *ctrl;
|
||||
GstController *ctrl, *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 */
|
||||
|
@ -373,7 +390,28 @@ GST_START_TEST (controller_new_okay2)
|
|||
fail_unless (ctrl != NULL, NULL);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl)->ref_count == 1);
|
||||
|
||||
ctrl2 = gst_controller_new (G_OBJECT (elem), "boolean", NULL);
|
||||
fail_unless (ctrl2 != NULL, NULL);
|
||||
fail_unless (ctrl2 == ctrl, NULL);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl)->ref_count);
|
||||
fail_unless (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 (G_OBJECT (ctrl)->ref_count == 3);
|
||||
|
||||
g_object_unref (ctrl);
|
||||
g_object_unref (ctrl2);
|
||||
g_object_unref (ctrl3);
|
||||
gst_object_unref (elem);
|
||||
}
|
||||
|
||||
|
@ -385,6 +423,8 @@ 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 */
|
||||
|
@ -402,7 +442,10 @@ GST_START_TEST (controller_new_okay3)
|
|||
fail_unless (ctrl1 == ctrl3, NULL);
|
||||
|
||||
GST_INFO ("controller->ref_count=%d", G_OBJECT (ctrl1)->ref_count);
|
||||
fail_unless (G_OBJECT (ctrl1)->ref_count == 3);
|
||||
g_object_unref (ctrl1);
|
||||
g_object_unref (ctrl2);
|
||||
g_object_unref (ctrl3);
|
||||
gst_object_unref (elem);
|
||||
}
|
||||
|
||||
|
@ -415,6 +458,8 @@ GST_START_TEST (controller_param_twice)
|
|||
GstElement *elem;
|
||||
gboolean res;
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and should be controllable */
|
||||
|
@ -442,6 +487,8 @@ 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 */
|
||||
|
@ -468,6 +515,8 @@ GST_START_TEST (controller_interpolate_none)
|
|||
gboolean res;
|
||||
GValue val_ulong = { 0, };
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and should be controllable */
|
||||
|
@ -509,6 +558,8 @@ GST_START_TEST (controller_interpolate_trigger)
|
|||
gboolean res;
|
||||
GValue val_ulong = { 0, };
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and should be controllable */
|
||||
|
@ -552,6 +603,8 @@ GST_START_TEST (controller_interpolate_linear)
|
|||
gboolean res;
|
||||
GValue val_ulong = { 0, };
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and should be controllable */
|
||||
|
@ -593,6 +646,8 @@ GST_START_TEST (controller_unset)
|
|||
gboolean res;
|
||||
GValue val_ulong = { 0, };
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and should be controllable */
|
||||
|
@ -647,6 +702,8 @@ GST_START_TEST (controller_unset_all)
|
|||
gboolean res;
|
||||
GValue val_ulong = { 0, };
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and should be controllable */
|
||||
|
@ -694,6 +751,8 @@ GST_START_TEST (controller_live)
|
|||
gboolean res;
|
||||
GValue val_ulong = { 0, };
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("testmonosource", "test_source");
|
||||
|
||||
/* that property should exist and should be controllable */
|
||||
|
@ -745,6 +804,8 @@ GST_START_TEST (controller_helper_any_gobject)
|
|||
GstElement *elem;
|
||||
gboolean res;
|
||||
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
elem = gst_element_factory_make ("bin", "test_elem");
|
||||
|
||||
/* that element is not controllable */
|
||||
|
@ -756,8 +817,48 @@ GST_START_TEST (controller_helper_any_gobject)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (controller_misc)
|
||||
{
|
||||
GstController *ctrl;
|
||||
GstTimedValue *tval;
|
||||
GstElement *elem;
|
||||
GSList *list = NULL;
|
||||
|
||||
Suite *
|
||||
gst_controller_init (NULL, NULL);
|
||||
|
||||
/* test that an invalid timestamp throws a warning of some sort */
|
||||
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);
|
||||
|
||||
/* set interpolation mode */
|
||||
gst_controller_set_interpolation_mode (ctrl, "ulong", GST_INTERPOLATE_LINEAR);
|
||||
|
||||
/* set control value */
|
||||
tval = g_new0 (GstTimedValue, 1);
|
||||
tval->timestamp = GST_CLOCK_TIME_NONE;
|
||||
g_value_init (&tval->value, G_TYPE_ULONG);
|
||||
g_value_set_ulong (&tval->value, 0);
|
||||
|
||||
list = g_slist_append (list, tval);
|
||||
|
||||
ASSERT_WARNING (fail_if (gst_controller_set_from_list (ctrl, "ulong", list)));
|
||||
|
||||
/* try again with a valid stamp, should work now */
|
||||
tval->timestamp = 0;
|
||||
fail_unless (gst_controller_set_from_list (ctrl, "ulong", list));
|
||||
|
||||
/* allocated GstTimedValue now belongs to the controller, but list not */
|
||||
g_slist_free (list);
|
||||
g_object_unref (ctrl);
|
||||
gst_object_unref (elem);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_controller_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("Controller");
|
||||
|
@ -782,6 +883,7 @@ gst_controller_suite (void)
|
|||
tcase_add_test (tc, controller_unset_all);
|
||||
tcase_add_test (tc, controller_live);
|
||||
tcase_add_test (tc, controller_helper_any_gobject);
|
||||
tcase_add_test (tc, controller_misc);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue