From 2c989ef3a7ec0fc0cdd99a1d0366d0fe69f65ae5 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Sat, 5 Jun 2010 17:22:17 +0100 Subject: tests: add small unit test for AC3 vs. JPEG typefinding issue --- configure.ac | 1 + tests/Makefile.am | 1 + tests/check/Makefile.am | 4 +++- tests/check/gst/typefindfunctions.c | 34 ++++++++++++++++++++++++++++++++++ tests/files/Makefile.am | 2 ++ tests/files/partialframe.mjpeg | Bin 0 -> 1600 bytes 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/files/Makefile.am create mode 100644 tests/files/partialframe.mjpeg diff --git a/configure.ac b/configure.ac index 540a9d0ff..d49f57ca0 100644 --- a/configure.ac +++ b/configure.ac @@ -953,6 +953,7 @@ tests/examples/volume/Makefile tests/examples/snapshot/Makefile tests/examples/gio/Makefile tests/examples/v4l/Makefile +tests/files/Makefile tests/icles/Makefile docs/Makefile docs/design/Makefile diff --git a/tests/Makefile.am b/tests/Makefile.am index b5c677c0e..de36755be 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,4 +24,5 @@ SUBDIRS = \ DIST_SUBDIRS = \ check \ examples \ + files \ icles diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 8c636dc90..831ad9dc0 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -1,6 +1,7 @@ include $(top_srcdir)/common/check.mak CHECK_REGISTRY = $(top_builddir)/tests/check/test-registry.reg +TEST_FILES_DIRECTORY = $(top_srcdir)/tests/files REGISTRY_ENVIRONMENT = \ GST_REGISTRY=$(CHECK_REGISTRY) @@ -136,7 +137,8 @@ VALGRIND_TO_FIX = \ # these tests don't even pass noinst_PROGRAMS = $(check_libvisual) -AM_CFLAGS = $(GST_CFLAGS) $(GST_CHECK_CFLAGS) +AM_CFLAGS = $(GST_CFLAGS) $(GST_CHECK_CFLAGS) \ + -DGST_TEST_FILES_PATH="\"$(TEST_FILES_DIRECTORY)\"" LDADD = $(GST_LIBS) $(GST_CHECK_LIBS) # valgrind testing diff --git a/tests/check/gst/typefindfunctions.c b/tests/check/gst/typefindfunctions.c index 08d3f1bc5..04c873e4a 100644 --- a/tests/check/gst/typefindfunctions.c +++ b/tests/check/gst/typefindfunctions.c @@ -103,7 +103,40 @@ GST_START_TEST (test_broken_flac_in_ogg) gst_buffer_unref (buf); gst_caps_unref (caps); +} + +GST_END_TEST; + +GST_START_TEST (test_jpeg_not_ac3) +{ + const gchar *type; + GstBuffer *buf; + GError *err = NULL; + GstCaps *caps = NULL; + gchar *path, *data = NULL; + gsize data_len; + path = g_build_filename (GST_TEST_FILES_PATH, "partialframe.mjpeg", NULL); + GST_LOG ("reading file '%s'", path); + if (!g_file_get_contents (path, &data, &data_len, &err)) { + g_error ("error loading test file: %s", err->message); + } + + buf = gst_buffer_new (); + GST_BUFFER_DATA (buf) = (guint8 *) data; + GST_BUFFER_SIZE (buf) = data_len; + GST_BUFFER_OFFSET (buf) = 0; + + caps = gst_type_find_helper_for_buffer (NULL, buf, NULL); + 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, "image/jpeg"); + + gst_buffer_unref (buf); + gst_caps_unref (caps); + g_free (data); } GST_END_TEST; @@ -118,6 +151,7 @@ typefindfunctions_suite (void) tcase_add_test (tc_chain, test_quicktime_mpeg4video); tcase_add_test (tc_chain, test_broken_flac_in_ogg); + tcase_add_test (tc_chain, test_jpeg_not_ac3); return s; } diff --git a/tests/files/Makefile.am b/tests/files/Makefile.am new file mode 100644 index 000000000..5258f24d1 --- /dev/null +++ b/tests/files/Makefile.am @@ -0,0 +1,2 @@ +EXTRA_DIST = \ + partialframe.mjpeg diff --git a/tests/files/partialframe.mjpeg b/tests/files/partialframe.mjpeg new file mode 100644 index 000000000..fe8621e1f Binary files /dev/null and b/tests/files/partialframe.mjpeg differ -- cgit v1.2.3