summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cceab6e)
raw | patch | inline | side by side (parent: cceab6e)
author | Thomas Vander Stichele <thomas@apestaart.org> | |
Sun, 2 Jul 2006 09:04:45 +0000 (09:04 +0000) | ||
committer | Thomas Vander Stichele <thomas@apestaart.org> | |
Sun, 2 Jul 2006 09:04:45 +0000 (09:04 +0000) |
Original commit message from CVS:
* libs/gst/dataprotocol/Makefile.am:
build dataprotocol test by linking to the lib, instead of
compiling the source, so we get coverage
* tests/check/Makefile.am:
* tests/check/elements/filesrc.c: (event_func), (setup_filesrc),
(cleanup_filesrc), (GST_START_TEST), (filesrc_suite):
add a test for filesrc
* libs/gst/dataprotocol/Makefile.am:
build dataprotocol test by linking to the lib, instead of
compiling the source, so we get coverage
* tests/check/Makefile.am:
* tests/check/elements/filesrc.c: (event_func), (setup_filesrc),
(cleanup_filesrc), (GST_START_TEST), (filesrc_suite):
add a test for filesrc
ChangeLog | patch | blob | history | |
libs/gst/dataprotocol/Makefile.am | patch | blob | history | |
tests/check/Makefile.am | patch | blob | history | |
tests/check/elements/filesrc.c | [new file with mode: 0644] | patch | blob |
diff --git a/ChangeLog b/ChangeLog
index 99d3dc20f239c6cbc65af59e015fd1e4d502df5a..ea0a715715bdb0cb51a1ce21c565ae92c84c5caa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-07-02 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * libs/gst/dataprotocol/Makefile.am:
+ build dataprotocol test by linking to the lib, instead of
+ compiling the source, so we get coverage
+ * tests/check/Makefile.am:
+ * tests/check/elements/filesrc.c: (event_func), (setup_filesrc),
+ (cleanup_filesrc), (GST_START_TEST), (filesrc_suite):
+ add a test for filesrc
+
2006-07-02 Thomas Vander Stichele <thomas at apestaart dot org>
* tests/check/gst/gststructure.c: (GST_START_TEST),
index eca8c6213f979a61560e0b7d66878d6c9e1a3aef..408e4ba97d5250ddc30ec5ee8379d470438ec193 100644 (file)
libgstdataprotocol_@GST_MAJORMINOR@_la_LIBADD = $(GST_OBJ_LIBS)
libgstdataprotocol_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
-CLEANFILES = *.gcno *.gcda *.gcov
+CLEANFILES = *.gcno *.gcda *.gcov *.gcov.out
%.c.gcov: .libs/libgstdataprotocol_@GST_MAJORMINOR@_la-%.gcda %.c
$(GCOV) -b -f -o $^ > $@.out
index 2b9974b630ee1f61958779aaa909d5518fce4551..872bf12e70a91992dabcb9007a2f2c47cf91c061 100644 (file)
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
elements/fakesink \
elements/fakesrc \
elements/fdsrc \
+ elements/filesrc \
elements/identity \
libs/basesrc \
libs/controller \
$(CHECK_LIBS)
libs_gdp_SOURCES = \
- libs/gdp.c \
- $(top_srcdir)/libs/gst/dataprotocol/dataprotocol.c
+ libs/gdp.c
libs_gdp_CFLAGS = $(AM_CFLAGS)
+libs_gdp_LDADD = \
+ $(top_builddir)/libs/gst/dataprotocol/libgstdataprotocol-@GST_MAJORMINOR@.la \
+ $(LDADD)
elements_fdsrc_CFLAGS=$(GST_OBJ_CFLAGS) $(CHECK_CFLAGS) -DTESTFILE=\"$(top_srcdir)/configure.ac\"
+elements_filesrc_CFLAGS=$(GST_OBJ_CFLAGS) $(CHECK_CFLAGS) -DTESTFILE=\"$(top_srcdir)/configure.ac\"
libs_basesrc_LDADD = \
$(top_builddir)/libs/gst/base/libgstbase-@GST_MAJORMINOR@.la \
diff --git a/tests/check/elements/filesrc.c b/tests/check/elements/filesrc.c
--- /dev/null
@@ -0,0 +1,137 @@
+/* GStreamer
+ *
+ * Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
+ *
+ * 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 <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <gst/check/gstcheck.h>
+
+gboolean have_eos = FALSE;
+
+GstPad *mysinkpad;
+
+static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+gboolean
+event_func (GstPad * pad, GstEvent * event)
+{
+ if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
+ have_eos = TRUE;
+ gst_event_unref (event);
+ return TRUE;
+ }
+
+ gst_event_unref (event);
+ return FALSE;
+}
+
+GstElement *
+setup_filesrc ()
+{
+ GstElement *filesrc;
+
+ GST_DEBUG ("setup_filesrc");
+ filesrc = gst_check_setup_element ("filesrc");
+ mysinkpad = gst_check_setup_sink_pad (filesrc, &sinktemplate, NULL);
+ gst_pad_set_event_function (mysinkpad, event_func);
+ gst_pad_set_active (mysinkpad, TRUE);
+ return filesrc;
+}
+
+void
+cleanup_filesrc (GstElement * filesrc)
+{
+ gst_check_teardown_sink_pad (filesrc);
+ gst_check_teardown_element (filesrc);
+}
+
+GST_START_TEST (test_seeking)
+{
+ GstElement *src;
+ GstQuery *seeking_query;
+ gboolean seekable;
+
+#ifndef TESTFILE
+#error TESTFILE not defined
+#endif
+ src = setup_filesrc ();
+
+ g_object_set (G_OBJECT (src), "location", TESTFILE, NULL);
+ fail_unless (gst_element_set_state (src,
+ GST_STATE_PAUSED) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to paused");
+
+ /* Test that filesrc is seekable with a file fd */
+ fail_unless ((seeking_query = gst_query_new_seeking (GST_FORMAT_BYTES))
+ != NULL);
+ fail_unless (gst_element_query (src, seeking_query) == TRUE);
+ gst_query_parse_seeking (seeking_query, NULL, &seekable, NULL, NULL);
+ fail_unless (seekable == TRUE);
+ gst_query_unref (seeking_query);
+
+ fail_unless (gst_element_set_state (src,
+ GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
+
+ /* cleanup */
+ cleanup_filesrc (src);
+}
+
+GST_END_TEST;
+
+GST_START_TEST (test_coverage)
+{
+ GstElement *src;
+ gchar *location;
+
+ src = setup_filesrc ();
+
+ g_object_set (G_OBJECT (src), "location", "/i/do/not/exist", NULL);
+ g_object_get (G_OBJECT (src), "location", &location, NULL);
+ fail_unless_equals_string (location, "/i/do/not/exist");
+ g_free (location);
+ g_object_set (G_OBJECT (src), "location", NULL, NULL);
+ g_object_get (G_OBJECT (src), "location", &location, NULL);
+ fail_if (location);
+
+ /* cleanup */
+ cleanup_filesrc (src);
+}
+
+GST_END_TEST;
+
+Suite *
+filesrc_suite (void)
+{
+ Suite *s = suite_create ("filesrc");
+ TCase *tc_chain = tcase_create ("general");
+
+ suite_add_tcase (s, tc_chain);
+ tcase_add_test (tc_chain, test_seeking);
+ tcase_add_test (tc_chain, test_coverage);
+
+ return s;
+}
+
+GST_CHECK_MAIN (filesrc);