1 /* GStreamer unit test for multifile plugin
3 * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
25 #include <glib/gstdio.h>
28 #include <gst/check/gstcheck.h>
33 run_pipeline (GstElement * pipeline)
35 gst_element_set_state (pipeline, GST_STATE_PAUSED);
36 gst_element_get_state (pipeline, NULL, NULL, -1);
37 gst_element_set_state (pipeline, GST_STATE_PLAYING);
40 gst_element_set_state (pipeline, GST_STATE_NULL);
44 g_mkdtemp (const gchar * template)
49 s = g_strdup (template);
57 GST_START_TEST (test_multifilesink)
67 tmpdir = g_get_tmp_dir ();
68 template = g_build_filename (tmpdir, "multifile-test-XXXXXX", NULL);
69 my_tmpdir = g_mkdtemp (template);
70 fail_if (my_tmpdir == NULL);
74 ("videotestsrc num-buffers=10 ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! multifilesink",
76 fail_if (pipeline == NULL);
77 mfs = gst_bin_get_by_name (GST_BIN (pipeline), "multifilesink0");
78 fail_if (mfs == NULL);
79 mfs_pattern = g_build_filename (my_tmpdir, "%05d", NULL);
80 g_object_set (G_OBJECT (mfs), "location", mfs_pattern, NULL);
82 run_pipeline (pipeline);
83 gst_object_unref (pipeline);
85 for (i = 0; i < 10; i++) {
88 s = g_strdup_printf (mfs_pattern, i);
89 fail_if (g_remove (s) != 0);
92 fail_if (g_remove (my_tmpdir) != 0);
101 GST_START_TEST (test_multifilesrc)
103 GstElement *pipeline;
111 tmpdir = g_get_tmp_dir ();
112 template = g_build_filename (tmpdir, "multifile-test-XXXXXX", NULL);
113 my_tmpdir = g_mkdtemp (template);
114 fail_if (my_tmpdir == NULL);
118 ("videotestsrc num-buffers=10 ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240 ! multifilesink",
120 fail_if (pipeline == NULL);
121 mfs = gst_bin_get_by_name (GST_BIN (pipeline), "multifilesink0");
122 fail_if (mfs == NULL);
123 mfs_pattern = g_build_filename (my_tmpdir, "%05d", NULL);
124 g_object_set (G_OBJECT (mfs), "location", mfs_pattern, NULL);
125 g_free (mfs_pattern);
126 g_object_unref (mfs);
127 run_pipeline (pipeline);
128 gst_object_unref (pipeline);
132 ("multifilesrc ! video/x-raw-yuv,format=(fourcc)I420,width=320,height=240,framerate=10/1 ! fakesink",
134 fail_if (pipeline == NULL);
135 mfs = gst_bin_get_by_name (GST_BIN (pipeline), "multifilesrc0");
136 fail_if (mfs == NULL);
137 mfs_pattern = g_build_filename (my_tmpdir, "%05d", NULL);
138 g_object_set (G_OBJECT (mfs), "location", mfs_pattern, NULL);
139 g_object_unref (mfs);
140 run_pipeline (pipeline);
141 gst_object_unref (pipeline);
143 for (i = 0; i < 10; i++) {
146 s = g_strdup_printf (mfs_pattern, i);
147 fail_if (g_remove (s) != 0);
150 fail_if (g_remove (my_tmpdir) != 0);
152 g_free (mfs_pattern);
160 libvisual_suite (void)
162 Suite *s = suite_create ("multifile");
163 TCase *tc_chain = tcase_create ("general");
165 suite_add_tcase (s, tc_chain);
167 tcase_add_test (tc_chain, test_multifilesink);
168 tcase_add_test (tc_chain, test_multifilesrc);
173 GST_CHECK_MAIN (libvisual);