diff --git a/ChangeLog b/ChangeLog index ad0bde1511..44ac9452ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-02-16 Thomas Vander Stichele + + * check/Makefile.am: + * check/gst/gstpad.c: + add pad tests + 2005-02-16 Wim Taymans * docs/design/part-TODO.txt: diff --git a/check/Makefile.am b/check/Makefile.am index 7a7dd1afa2..5d1fe03b87 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -5,11 +5,12 @@ TESTS_ENVIRONMENT=\ plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@ # make all tests depend on the versioned gst-register -$(TESTS): $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ +#$(TESTS): $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ # rebuild gst-register-@GST_MAJORMINOR@ if needed # the EXEEXT is because am 1.6 complained about overrides -$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@$(EXEEXT): +#$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@$(EXEEXT): +$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@: cd $(top_builddir)/tools && make # override to _not_ install the test plugins @@ -19,10 +20,13 @@ install-pluginLTLIBRARIES: # dumps have PIDs appended CLEANFILES = core.* -TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ \ +#TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ + +TESTS = \ gst/gstcaps \ gst/gstdata \ gst/gstobject \ + gst/gstpad \ gst-libs/gdp check_PROGRAMS = $(TESTS) diff --git a/check/gst/gstpad.c b/check/gst/gstpad.c new file mode 100644 index 0000000000..738e0e283d --- /dev/null +++ b/check/gst/gstpad.c @@ -0,0 +1,86 @@ +/* GStreamer + * Copyright (C) <2005> Thomas Vander Stichele + * + * gstpad.c: Unit test for GstPad + * + * 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 "../gstcheck.h" + +START_TEST (test_link) +{ + GstPad *src, *sink; + GstPadTemplate *srct; //, *sinkt; + GstCaps *srcc; + + GstPadLinkReturn ret; + gchar *name; + + src = gst_pad_new ("source", GST_PAD_SRC); + fail_if (src == NULL); + + name = gst_pad_get_name (src); + fail_unless (strcmp (name, "source") == 0); + + sink = gst_pad_new ("sink", GST_PAD_SINK); + fail_if (sink == NULL); + + /* linking without templates should fail */ + ret = gst_pad_link (src, sink); + fail_unless (ret == GST_PAD_LINK_NOFORMAT); + + ASSERT_CRITICAL (gst_pad_get_pad_template (NULL)); + + srct = gst_pad_get_pad_template (src); + fail_unless (srct == NULL); + + /* create caps */ + srcc = gst_caps_new_any (); + gst_pad_set_caps (src, srcc); + gst_pad_set_caps (sink, srcc); + + /* linking with any caps should succeed */ + ret = gst_pad_link (src, sink); + fail_unless (ret == GST_PAD_LINK_OK); +} + +END_TEST Suite * gst_pad_suite (void) +{ + Suite *s = suite_create ("GstPad"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_link); + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = gst_pad_suite (); + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +} diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 7a7dd1afa2..5d1fe03b87 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -5,11 +5,12 @@ TESTS_ENVIRONMENT=\ plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@ # make all tests depend on the versioned gst-register -$(TESTS): $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ +#$(TESTS): $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ # rebuild gst-register-@GST_MAJORMINOR@ if needed # the EXEEXT is because am 1.6 complained about overrides -$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@$(EXEEXT): +#$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@$(EXEEXT): +$(top_builddir)/tools/gst-register-@GST_MAJORMINOR@: cd $(top_builddir)/tools && make # override to _not_ install the test plugins @@ -19,10 +20,13 @@ install-pluginLTLIBRARIES: # dumps have PIDs appended CLEANFILES = core.* -TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ \ +#TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ + +TESTS = \ gst/gstcaps \ gst/gstdata \ gst/gstobject \ + gst/gstpad \ gst-libs/gdp check_PROGRAMS = $(TESTS) diff --git a/tests/check/gst/gstpad.c b/tests/check/gst/gstpad.c new file mode 100644 index 0000000000..738e0e283d --- /dev/null +++ b/tests/check/gst/gstpad.c @@ -0,0 +1,86 @@ +/* GStreamer + * Copyright (C) <2005> Thomas Vander Stichele + * + * gstpad.c: Unit test for GstPad + * + * 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 "../gstcheck.h" + +START_TEST (test_link) +{ + GstPad *src, *sink; + GstPadTemplate *srct; //, *sinkt; + GstCaps *srcc; + + GstPadLinkReturn ret; + gchar *name; + + src = gst_pad_new ("source", GST_PAD_SRC); + fail_if (src == NULL); + + name = gst_pad_get_name (src); + fail_unless (strcmp (name, "source") == 0); + + sink = gst_pad_new ("sink", GST_PAD_SINK); + fail_if (sink == NULL); + + /* linking without templates should fail */ + ret = gst_pad_link (src, sink); + fail_unless (ret == GST_PAD_LINK_NOFORMAT); + + ASSERT_CRITICAL (gst_pad_get_pad_template (NULL)); + + srct = gst_pad_get_pad_template (src); + fail_unless (srct == NULL); + + /* create caps */ + srcc = gst_caps_new_any (); + gst_pad_set_caps (src, srcc); + gst_pad_set_caps (sink, srcc); + + /* linking with any caps should succeed */ + ret = gst_pad_link (src, sink); + fail_unless (ret == GST_PAD_LINK_OK); +} + +END_TEST Suite * gst_pad_suite (void) +{ + Suite *s = suite_create ("GstPad"); + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_link); + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = gst_pad_suite (); + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +}