add pad tests

Original commit message from CVS:
add pad tests
This commit is contained in:
Thomas Vander Stichele 2005-02-16 17:34:32 +00:00
parent dc44130c0e
commit a0845b59e6
5 changed files with 192 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2005-02-16 Thomas Vander Stichele <thomas at apestaart dot org>
* check/Makefile.am:
* check/gst/gstpad.c:
add pad tests
2005-02-16 Wim Taymans <wim@fluendo.com> 2005-02-16 Wim Taymans <wim@fluendo.com>
* docs/design/part-TODO.txt: * docs/design/part-TODO.txt:

View file

@ -5,11 +5,12 @@ TESTS_ENVIRONMENT=\
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@ plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
# make all tests depend on the versioned gst-register # 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 # rebuild gst-register-@GST_MAJORMINOR@ if needed
# the EXEEXT is because am 1.6 complained about overrides # 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 cd $(top_builddir)/tools && make
# override to _not_ install the test plugins # override to _not_ install the test plugins
@ -19,10 +20,13 @@ install-pluginLTLIBRARIES:
# dumps have PIDs appended # dumps have PIDs appended
CLEANFILES = core.* CLEANFILES = core.*
TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ \ #TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@
TESTS = \
gst/gstcaps \ gst/gstcaps \
gst/gstdata \ gst/gstdata \
gst/gstobject \ gst/gstobject \
gst/gstpad \
gst-libs/gdp gst-libs/gdp
check_PROGRAMS = $(TESTS) check_PROGRAMS = $(TESTS)

86
check/gst/gstpad.c Normal file
View file

@ -0,0 +1,86 @@
/* GStreamer
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
*
* 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;
}

View file

@ -5,11 +5,12 @@ TESTS_ENVIRONMENT=\
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@ plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
# make all tests depend on the versioned gst-register # 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 # rebuild gst-register-@GST_MAJORMINOR@ if needed
# the EXEEXT is because am 1.6 complained about overrides # 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 cd $(top_builddir)/tools && make
# override to _not_ install the test plugins # override to _not_ install the test plugins
@ -19,10 +20,13 @@ install-pluginLTLIBRARIES:
# dumps have PIDs appended # dumps have PIDs appended
CLEANFILES = core.* CLEANFILES = core.*
TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@ \ #TESTS = $(top_builddir)/tools/gst-register-@GST_MAJORMINOR@
TESTS = \
gst/gstcaps \ gst/gstcaps \
gst/gstdata \ gst/gstdata \
gst/gstobject \ gst/gstobject \
gst/gstpad \
gst-libs/gdp gst-libs/gdp
check_PROGRAMS = $(TESTS) check_PROGRAMS = $(TESTS)

86
tests/check/gst/gstpad.c Normal file
View file

@ -0,0 +1,86 @@
/* GStreamer
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
*
* 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;
}