2 * Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
4 * gstbin.c: Unit test for GstBin
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "../gstcheck.h"
24 START_TEST (test_interface)
31 bin = GST_BIN (gst_bin_new (NULL));
32 fail_unless (bin != NULL, "Could not create bin");
34 filesrc = gst_element_factory_make ("filesrc", NULL);
35 fail_unless (filesrc != NULL, "Could not create filesrc");
36 fail_unless (GST_IS_URI_HANDLER (filesrc), "Filesrc not a URI handler");
37 gst_bin_add (bin, filesrc);
39 fail_unless (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
40 it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
41 fail_unless (it != NULL);
42 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
43 fail_unless (item == (gpointer) filesrc);
44 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
45 gst_iterator_free (it);
47 gst_bin_add_many (bin,
48 gst_element_factory_make ("identity", NULL),
49 gst_element_factory_make ("identity", NULL),
50 gst_element_factory_make ("identity", NULL), NULL);
51 fail_unless (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
52 it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
53 fail_unless (it != NULL);
54 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
55 fail_unless (item == (gpointer) filesrc);
56 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
57 gst_iterator_free (it);
60 bin = GST_BIN (gst_bin_new (NULL));
61 fail_unless (bin != NULL);
62 gst_bin_add_many (bin,
63 gst_element_factory_make ("identity", NULL),
64 gst_element_factory_make ("identity", NULL),
65 GST_ELEMENT (bin2), gst_element_factory_make ("identity", NULL), NULL);
66 fail_unless (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc);
67 it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
68 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
69 fail_unless (item == (gpointer) filesrc);
70 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
71 gst_iterator_free (it);
73 gst_bin_add (bin, gst_element_factory_make ("filesrc", NULL));
74 gst_bin_add (bin2, gst_element_factory_make ("filesrc", NULL));
75 it = gst_bin_iterate_all_by_interface (bin, GST_TYPE_URI_HANDLER);
76 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
77 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
78 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_OK);
79 fail_unless (gst_iterator_next (it, &item) == GST_ITERATOR_DONE);
80 gst_iterator_free (it);
82 gst_object_unref (GST_OBJECT (bin));
84 END_TEST Suite * gst_bin_suite (void)
86 Suite *s = suite_create ("GstBin");
87 TCase *tc_chain = tcase_create ("bin tests");
89 suite_add_tcase (s, tc_chain);
90 tcase_add_test (tc_chain, test_interface);
96 main (int argc, char **argv)
100 Suite *s = gst_bin_suite ();
101 SRunner *sr = srunner_create (s);
103 gst_check_init (&argc, &argv);
105 srunner_run_all (sr, CK_NORMAL);
106 nf = srunner_ntests_failed (sr);