mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
gstobject: Add simple unit test for gst_object_has_ancestor()
This commit is contained in:
parent
87058ab28e
commit
4917bb4fc2
1 changed files with 51 additions and 0 deletions
|
@ -453,6 +453,55 @@ GST_START_TEST (test_fake_object_parentage_dispose)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_fake_object_has_ancestor)
|
||||||
|
{
|
||||||
|
GstObject *object1, *object2, *object3, *object4;
|
||||||
|
gboolean result;
|
||||||
|
|
||||||
|
object1 = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
fail_if (object1 == NULL, "Failed to create instance of GstFakeObject");
|
||||||
|
|
||||||
|
object2 = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
fail_if (object2 == NULL, "Failed to create instance of GstFakeObject");
|
||||||
|
|
||||||
|
object3 = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
fail_if (object3 == NULL, "Failed to create instance of GstFakeObject");
|
||||||
|
|
||||||
|
object4 = g_object_new (gst_fake_object_get_type (), NULL);
|
||||||
|
fail_if (object4 == NULL, "Failed to create instance of GstFakeObject");
|
||||||
|
|
||||||
|
/* try to set other object as parent */
|
||||||
|
result = gst_object_set_parent (object1, object3);
|
||||||
|
fail_if (result == FALSE,
|
||||||
|
"GstFakeObject could not accept other object as parent");
|
||||||
|
result = gst_object_set_parent (object2, object3);
|
||||||
|
fail_if (result == FALSE,
|
||||||
|
"GstFakeObject could not accept other object as parent");
|
||||||
|
result = gst_object_set_parent (object3, object4);
|
||||||
|
fail_if (result == FALSE,
|
||||||
|
"GstFakeObject could not accept other object as parent");
|
||||||
|
|
||||||
|
fail_unless (gst_object_has_ancestor (object1, object1));
|
||||||
|
fail_if (gst_object_has_ancestor (object1, object2));
|
||||||
|
fail_unless (gst_object_has_ancestor (object1, object3));
|
||||||
|
fail_unless (gst_object_has_ancestor (object1, object4));
|
||||||
|
fail_if (gst_object_has_ancestor (object3, object1));
|
||||||
|
fail_if (gst_object_has_ancestor (object4, object1));
|
||||||
|
fail_unless (gst_object_has_ancestor (object3, object4));
|
||||||
|
fail_if (gst_object_has_ancestor (object4, object3));
|
||||||
|
fail_unless (gst_object_has_ancestor (object4, object4));
|
||||||
|
|
||||||
|
/* unparent everything */
|
||||||
|
gst_object_unparent (object3);
|
||||||
|
gst_object_unparent (object2);
|
||||||
|
gst_object_unparent (object1);
|
||||||
|
|
||||||
|
/* now dispose objects */
|
||||||
|
gst_object_unref (object4);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
/* test: try renaming a parented object, make sure it fails */
|
/* test: try renaming a parented object, make sure it fails */
|
||||||
|
|
||||||
static Suite *
|
static Suite *
|
||||||
|
@ -474,6 +523,8 @@ gst_object_suite (void)
|
||||||
tcase_add_test (tc_chain, test_fake_object_name_threaded_unique);
|
tcase_add_test (tc_chain, test_fake_object_name_threaded_unique);
|
||||||
tcase_add_test (tc_chain, test_fake_object_parentage);
|
tcase_add_test (tc_chain, test_fake_object_parentage);
|
||||||
tcase_add_test (tc_chain, test_fake_object_parentage_dispose);
|
tcase_add_test (tc_chain, test_fake_object_parentage_dispose);
|
||||||
|
|
||||||
|
tcase_add_test (tc_chain, test_fake_object_has_ancestor);
|
||||||
//tcase_add_checked_fixture (tc_chain, setup, teardown);
|
//tcase_add_checked_fixture (tc_chain, setup, teardown);
|
||||||
|
|
||||||
/* FIXME: GLib shouldn't crash here, but issue a warning and return a NULL
|
/* FIXME: GLib shouldn't crash here, but issue a warning and return a NULL
|
||||||
|
|
Loading…
Reference in a new issue