summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStefan Kost <ensonic@users.sourceforge.net>2007-07-19 09:08:30 +0000
committerStefan Kost <ensonic@users.sourceforge.net>2007-07-19 09:08:30 +0000
commit6cbacb8a1497c21208edd0507986c2e263d17bfc (patch)
tree2aa99a9f9f7d7600c587e1899953d4625277dc37 /tests
parenta6058388c17adeace60b9e8b1daa2087f788e717 (diff)
downloadgst-plugins-bad-6cbacb8a1497c21208edd0507986c2e263d17bfc.tar.gz
gst-plugins-bad-6cbacb8a1497c21208edd0507986c2e263d17bfc.tar.bz2
gst-plugins-bad-6cbacb8a1497c21208edd0507986c2e263d17bfc.zip
tests/check/Makefile.am: tests/check/elements/timidity.c (GST_START_TEST, timidity_suite, main):
Original commit message from CVS: * tests/check/Makefile.am: * tests/check/elements/timidity.c (GST_START_TEST, timidity_suite, main): Add typefind test for midi.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/Makefile.am11
-rw-r--r--tests/check/elements/timidity.c89
2 files changed, 100 insertions, 0 deletions
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index 9856fda5..6801c05e 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -38,6 +38,13 @@ else
check_neon =
endif
+if USE_TIMIDITY
+check_timidity=elements/timidity
+else
+check_timidity=
+endif
+
+
VALGRIND_TO_FIX = \
elements/mpeg2enc
@@ -48,6 +55,7 @@ VALGRIND_TESTS_DISABLE = \
check_PROGRAMS = \
$(check_mpeg2enc) \
$(check_neon) \
+ $(check_timidity) \
elements/rganalysis \
elements/rglimiter \
elements/rgvolume \
@@ -59,3 +67,6 @@ TESTS = $(check_PROGRAMS)
AM_CFLAGS = $(GST_OBJ_CFLAGS) $(GST_CHECK_CFLAGS) $(CHECK_CFLAGS)
LDADD = $(GST_OBJ_LIBS) $(GST_CHECK_LIBS) $(CHECK_LIBS)
+elements_timidity_CFLAGS = $(GST_BASE_CFLAGS) $(AM_CFLAGS)
+elements_timidity_LDADD = $(GST_BASE_LIBS) $(LDADD)
+
diff --git a/tests/check/elements/timidity.c b/tests/check/elements/timidity.c
new file mode 100644
index 00000000..4470eae3
--- /dev/null
+++ b/tests/check/elements/timidity.c
@@ -0,0 +1,89 @@
+/* GStreamer
+ *
+ * unit test for timidity/wildmidi
+ *
+ * Copyright (C) <2007> Stefan Kost <ensonic@users.sf.net>
+ *
+ * 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 <gst/check/gstcheck.h>
+#include <gst/base/gsttypefindhelper.h>
+
+
+GST_START_TEST (test_midi_typefind)
+{
+ const guint8 midi_header[] = {
+ 0x4d, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x60, 0x4d, 0x54,
+ 0x72, 0x6b, 0x00, 0x00
+ };
+ GstTypeFindProbability prob;
+ const gchar *type;
+ GstBuffer *buf;
+ GstCaps *caps = NULL;
+
+ buf = gst_buffer_new ();
+ GST_BUFFER_DATA (buf) = (guint8 *) midi_header;
+ GST_BUFFER_SIZE (buf) = sizeof (midi_header);
+ GST_BUFFER_OFFSET (buf) = 0;
+
+ caps = gst_type_find_helper_for_buffer (NULL, buf, &prob);
+ fail_unless (caps != NULL);
+ GST_LOG ("Found type: %" GST_PTR_FORMAT, caps);
+
+ type = gst_structure_get_name (gst_caps_get_structure (caps, 0));
+ fail_unless_equals_string (type, "audio/midi");
+ fail_unless (prob > GST_TYPE_FIND_MINIMUM && prob <= GST_TYPE_FIND_MAXIMUM);
+
+ gst_buffer_unref (buf);
+ gst_caps_unref (caps);
+
+}
+
+GST_END_TEST;
+
+
+Suite *
+timidity_suite (void)
+{
+ Suite *s = suite_create ("timidity");
+ TCase *tc_chain = tcase_create ("general");
+
+ suite_add_tcase (s, tc_chain);
+ tcase_add_test (tc_chain, test_midi_typefind);
+
+ return s;
+}
+
+int
+main (int argc, char **argv)
+{
+ int nf;
+
+ Suite *s = timidity_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;
+}