tests: add small unit test for AC3 vs. JPEG typefinding issue
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 5 Jun 2010 16:22:17 +0000 (17:22 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 5 Jun 2010 16:24:45 +0000 (17:24 +0100)
configure.ac
tests/Makefile.am
tests/check/Makefile.am
tests/check/gst/typefindfunctions.c
tests/files/Makefile.am [new file with mode: 0644]
tests/files/partialframe.mjpeg [new file with mode: 0644]

index 540a9d0ff8cb859bd98449ce6aa168811ef02290..d49f57ca046892fe175a3ac69879923ca6f9b4ae 100644 (file)
@@ -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
index b5c677c0e1cec2be46089770e9bf3dff6cd44ea1..de36755bed1ae9128fb66475c119e3fd3e219b08 100644 (file)
@@ -24,4 +24,5 @@ SUBDIRS =                     \
 DIST_SUBDIRS =                         \
        check                   \
        examples                \
+       files                   \
        icles
index 8c636dc90a06514c72280e46dfe133de2eed4aad..831ad9dc0bcc53a5a36a8978cf223e2dec8e0e93 100644 (file)
@@ -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
index 08d3f1bc531fc721d42420380bb09ce4746f50cb..04c873e4a5ee0df7ae0e1bcafbe98cc0c9a5beef 100644 (file)
@@ -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 (file)
index 0000000..5258f24
--- /dev/null
@@ -0,0 +1,2 @@
+EXTRA_DIST = \
+       partialframe.mjpeg
diff --git a/tests/files/partialframe.mjpeg b/tests/files/partialframe.mjpeg
new file mode 100644 (file)
index 0000000..fe8621e
Binary files /dev/null and b/tests/files/partialframe.mjpeg differ