2005-07-07 11:59:37 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for fakesrc
|
|
|
|
*
|
|
|
|
* Copyright (C) <2005> 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>
|
|
|
|
|
2005-08-20 12:14:28 +00:00
|
|
|
#include <gst/check/gstcheck.h>
|
2005-07-07 11:59:37 +00:00
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static gboolean have_eos = FALSE;
|
2005-07-07 11:59:37 +00:00
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static GstPad *mysinkpad;
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
|
2005-07-07 11:59:37 +00:00
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static gboolean
|
2011-11-17 11:40:45 +00:00
|
|
|
event_func (GstPad * pad, GstObject * parent, GstEvent * event)
|
2005-07-07 11:59:37 +00:00
|
|
|
{
|
|
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
|
|
|
have_eos = TRUE;
|
|
|
|
}
|
2005-07-12 09:41:00 +00:00
|
|
|
gst_event_unref (event);
|
2011-11-28 12:52:00 +00:00
|
|
|
return TRUE;
|
2005-07-07 11:59:37 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static GstElement *
|
|
|
|
setup_fakesrc (void)
|
2005-07-07 11:59:37 +00:00
|
|
|
{
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
GstElement *fakesrc;
|
2005-07-07 11:59:37 +00:00
|
|
|
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
GST_DEBUG ("setup_fakesrc");
|
|
|
|
fakesrc = gst_check_setup_element ("fakesrc");
|
2011-11-24 20:36:12 +00:00
|
|
|
mysinkpad = gst_check_setup_sink_pad (fakesrc, &sinktemplate);
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
gst_pad_set_event_function (mysinkpad, event_func);
|
2005-08-30 19:45:38 +00:00
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
2010-07-03 14:13:14 +00:00
|
|
|
have_eos = FALSE;
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
return fakesrc;
|
2005-08-05 06:55:03 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static void
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
cleanup_fakesrc (GstElement * fakesrc)
|
2005-08-05 06:55:03 +00:00
|
|
|
{
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
gst_check_teardown_sink_pad (fakesrc);
|
|
|
|
gst_check_teardown_element (fakesrc);
|
2005-08-05 06:55:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_num_buffers)
|
|
|
|
{
|
|
|
|
GstElement *src;
|
2005-07-07 11:59:37 +00:00
|
|
|
|
2005-08-05 06:55:03 +00:00
|
|
|
src = setup_fakesrc ();
|
|
|
|
g_object_set (G_OBJECT (src), "num-buffers", 3, NULL);
|
2005-07-07 11:59:37 +00:00
|
|
|
fail_unless (gst_element_set_state (src,
|
2005-09-02 15:42:00 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-07-07 11:59:37 +00:00
|
|
|
|
|
|
|
while (!have_eos) {
|
|
|
|
g_usleep (1000);
|
|
|
|
}
|
|
|
|
|
2010-07-03 14:13:14 +00:00
|
|
|
fail_unless_equals_int (g_list_length (buffers), 3);
|
2008-02-19 12:56:28 +00:00
|
|
|
gst_check_drop_buffers ();
|
2005-07-12 09:41:00 +00:00
|
|
|
|
2005-11-16 18:09:47 +00:00
|
|
|
fail_unless (gst_element_set_state (src,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
|
2005-07-12 09:41:00 +00:00
|
|
|
/* cleanup */
|
2005-08-05 06:55:03 +00:00
|
|
|
cleanup_fakesrc (src);
|
|
|
|
}
|
2005-07-12 09:41:00 +00:00
|
|
|
|
2005-08-05 06:55:03 +00:00
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sizetype_empty)
|
|
|
|
{
|
|
|
|
GstElement *src;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
src = setup_fakesrc ();
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "sizetype", 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (src,
|
2005-09-02 15:42:00 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-05 06:55:03 +00:00
|
|
|
|
|
|
|
while (!have_eos) {
|
|
|
|
g_usleep (1000);
|
|
|
|
}
|
|
|
|
|
2010-07-03 14:13:14 +00:00
|
|
|
fail_unless_equals_int (g_list_length (buffers), 100);
|
2005-08-05 06:55:03 +00:00
|
|
|
l = buffers;
|
|
|
|
while (l) {
|
|
|
|
GstBuffer *buf = l->data;
|
|
|
|
|
2011-03-21 18:15:27 +00:00
|
|
|
fail_unless (gst_buffer_get_size (buf) == 0);
|
2005-08-05 06:55:03 +00:00
|
|
|
l = l->next;
|
|
|
|
}
|
2008-02-19 12:56:28 +00:00
|
|
|
gst_check_drop_buffers ();
|
2005-08-05 06:55:03 +00:00
|
|
|
|
2005-11-16 18:09:47 +00:00
|
|
|
fail_unless (gst_element_set_state (src,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
|
2005-08-05 06:55:03 +00:00
|
|
|
/* cleanup */
|
|
|
|
cleanup_fakesrc (src);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sizetype_fixed)
|
|
|
|
{
|
|
|
|
GstElement *src;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
src = setup_fakesrc ();
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "sizetype", 2, NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "sizemax", 8192, NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (src,
|
2005-09-02 15:42:00 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-05 06:55:03 +00:00
|
|
|
|
|
|
|
while (!have_eos) {
|
|
|
|
g_usleep (1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
fail_unless (g_list_length (buffers) == 100);
|
|
|
|
l = buffers;
|
|
|
|
while (l) {
|
|
|
|
GstBuffer *buf = l->data;
|
|
|
|
|
2011-03-21 18:15:27 +00:00
|
|
|
fail_unless (gst_buffer_get_size (buf) == 8192);
|
2005-08-05 06:55:03 +00:00
|
|
|
l = l->next;
|
|
|
|
}
|
2008-02-19 12:56:28 +00:00
|
|
|
gst_check_drop_buffers ();
|
2005-08-05 06:55:03 +00:00
|
|
|
|
2005-11-16 18:09:47 +00:00
|
|
|
fail_unless (gst_element_set_state (src,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
|
2005-08-05 06:55:03 +00:00
|
|
|
/* cleanup */
|
|
|
|
cleanup_fakesrc (src);
|
2005-07-07 11:59:37 +00:00
|
|
|
}
|
|
|
|
|
2005-07-09 16:36:18 +00:00
|
|
|
GST_END_TEST;
|
2005-07-07 11:59:37 +00:00
|
|
|
|
2005-08-05 06:55:03 +00:00
|
|
|
GST_START_TEST (test_sizetype_random)
|
|
|
|
{
|
|
|
|
GstElement *src;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
src = setup_fakesrc ();
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "sizetype", 3, NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "sizemin", 4096, NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "sizemax", 8192, NULL);
|
|
|
|
g_object_set (G_OBJECT (src), "num-buffers", 100, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (src,
|
2005-09-02 15:42:00 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-05 06:55:03 +00:00
|
|
|
|
|
|
|
while (!have_eos) {
|
|
|
|
g_usleep (1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
fail_unless (g_list_length (buffers) == 100);
|
|
|
|
l = buffers;
|
|
|
|
while (l) {
|
|
|
|
GstBuffer *buf = l->data;
|
|
|
|
|
2011-03-21 18:15:27 +00:00
|
|
|
fail_if (gst_buffer_get_size (buf) > 8192);
|
|
|
|
fail_if (gst_buffer_get_size (buf) < 4096);
|
2005-08-05 06:55:03 +00:00
|
|
|
l = l->next;
|
|
|
|
}
|
2008-02-19 12:56:28 +00:00
|
|
|
gst_check_drop_buffers ();
|
2005-08-05 06:55:03 +00:00
|
|
|
|
2005-11-16 18:09:47 +00:00
|
|
|
fail_unless (gst_element_set_state (src,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
|
2005-08-05 06:55:03 +00:00
|
|
|
/* cleanup */
|
|
|
|
cleanup_fakesrc (src);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2005-10-07 15:22:38 +00:00
|
|
|
GST_START_TEST (test_no_preroll)
|
|
|
|
{
|
|
|
|
GstElement *src;
|
|
|
|
GstStateChangeReturn ret;
|
|
|
|
|
|
|
|
src = setup_fakesrc ();
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);
|
|
|
|
|
|
|
|
ret = gst_element_set_state (src, GST_STATE_PAUSED);
|
|
|
|
|
|
|
|
fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
|
|
|
|
"error going to paused the first time");
|
|
|
|
|
|
|
|
ret = gst_element_set_state (src, GST_STATE_PAUSED);
|
|
|
|
|
|
|
|
fail_unless (ret == GST_STATE_CHANGE_NO_PREROLL,
|
|
|
|
"error going to paused the second time");
|
|
|
|
|
2005-11-16 18:09:47 +00:00
|
|
|
fail_unless (gst_element_set_state (src,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
|
2005-10-07 15:22:38 +00:00
|
|
|
/* cleanup */
|
|
|
|
cleanup_fakesrc (src);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2005-08-05 06:55:03 +00:00
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static Suite *
|
2005-07-07 11:59:37 +00:00
|
|
|
fakesrc_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("fakesrc");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_test (tc_chain, test_num_buffers);
|
2005-08-05 06:55:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_sizetype_empty);
|
|
|
|
tcase_add_test (tc_chain, test_sizetype_fixed);
|
|
|
|
tcase_add_test (tc_chain, test_sizetype_random);
|
2005-10-07 15:22:38 +00:00
|
|
|
tcase_add_test (tc_chain, test_no_preroll);
|
2005-07-07 11:59:37 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2006-07-01 20:56:56 +00:00
|
|
|
GST_CHECK_MAIN (fakesrc);
|