From: <bi...@ke...> - 2006-09-16 15:40:59
|
CVS Root: /cvs/gstreamer Module: gnonlin Changes by: bilboed Date: Sat Sep 16 2006 15:40:58 UTC Log message: * tests/check/Makefile.am: * tests/check/common.h: Single header file that contains all the common functions and structures for the gnonlin tests. * tests/check/complex.c: * tests/check/gnlsource.c: (GST_START_TEST): * tests/check/simple.c: Switch to using common.h , makes test files smaller. * tests/check/gnloperation.c: (GST_START_TEST), (gnonlin_suite), (main): Created new test for gnloperations, starting with one that tests adding and removing operations, and checking that the outputted segments are correct. Modified files: . : ChangeLog tests/check : Makefile.am complex.c gnlsource.c simple.c Added files: tests/check : common.h gnloperation.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gnonlin/ChangeLog.diff?r1=1.153&r2=1.154 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gnonlin/tests/check/Makefile.am.diff?r1=1.12&r2=1.13 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gnonlin/tests/check/common.h?rev=1.1&content-type=text/vnd.viewcvs-markup http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gnonlin/tests/check/complex.c.diff?r1=1.6&r2=1.7 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gnonlin/tests/check/gnloperation.c?rev=1.1&content-type=text/vnd.viewcvs-markup http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gnonlin/tests/check/gnlsource.c.diff?r1=1.4&r2=1.5 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gnonlin/tests/check/simple.c.diff?r1=1.15&r2=1.16 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gnonlin/ChangeLog,v retrieving revision 1.153 retrieving revision 1.154 diff -u -d -r1.153 -r1.154 --- ChangeLog 7 Sep 2006 08:14:22 -0000 1.153 +++ ChangeLog 16 Sep 2006 15:40:46 -0000 1.154 @@ -1,3 +1,19 @@ +2006-09-16 Edward Hervey <ed...@fl...> + + * tests/check/Makefile.am: + * tests/check/common.h: + Single header file that contains all the common functions and structures + for the gnonlin tests. + * tests/check/complex.c: + * tests/check/gnlsource.c: (GST_START_TEST): + * tests/check/simple.c: + Switch to using common.h , makes test files smaller. + * tests/check/gnloperation.c: (GST_START_TEST), (gnonlin_suite), + (main): + Created new test for gnloperations, starting with one that tests adding + and removing operations, and checking that the outputted segments are + correct. 2006-09-07 Edward Hervey <ed...@fl...> * gnl/gnlfilesource.c: (gnl_filesource_class_init): Index: Makefile.am RCS file: /cvs/gstreamer/gnonlin/tests/check/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Makefile.am 10 May 2006 18:02:58 -0000 1.12 +++ Makefile.am 16 Sep 2006 15:40:46 -0000 1.13 @@ -24,7 +24,8 @@ check_PROGRAMS = \ ./simple \ ./complex \ - ./gnlsource + ./gnlsource \ + ./gnloperation # these tests don't even pass noinst_PROGRAMS = --- NEW FILE: common.h --- #include <gst/check/gstcheck.h> typedef struct _Segment { gdouble rate; GstFormat format; gint64 start, stop, position; } Segment; typedef struct _CollectStructure { GstElement *comp; GstElement *sink; guint64 last_time; gboolean gotsegment; GList *expected_segments; } CollectStructure; static GstElement * gst_element_factory_make_or_warn (const gchar * factoryname, const gchar * name) { GstElement * element; element = gst_element_factory_make (factoryname, name); fail_unless (element != NULL, "Failed to make element %s", factoryname); return element; } static void composition_pad_added_cb (GstElement *composition, GstPad *pad, CollectStructure * collect) fail_if (!(gst_element_link (composition, collect->sink))); /* return TRUE to discard the Segment */ static gboolean compare_segments (Segment * segment, GstEvent * event) gboolean update; gdouble rate; GstFormat format; gint64 start, stop, position; gst_event_parse_new_segment (event, &update, &rate, &format, &start, &stop, &position); GST_DEBUG ("Got NewSegment update:%d, rate:%f, format:%d, start:%"GST_TIME_FORMAT ", stop:%"GST_TIME_FORMAT", position:%"GST_TIME_FORMAT, update, rate, format, GST_TIME_ARGS (start), GST_TIME_ARGS (stop), GST_TIME_ARGS (position)); GST_DEBUG ("Expecting rate:%f, format:%d, start:%"GST_TIME_FORMAT segment->rate, segment->format, GST_TIME_ARGS (segment->start), GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->position)); if (update) { GST_DEBUG ("was update, ignoring"); return FALSE; } fail_if (rate != segment->rate); fail_if (format != segment->format); fail_if (start != segment->start); fail_if (stop != segment->stop); fail_if (position != segment->position); GST_DEBUG ("Segment was valid, discarding expected Segment"); return TRUE; sinkpad_event_probe (GstPad * sinkpad, GstEvent * event, CollectStructure * collect) Segment * segment; if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) { fail_if (collect->expected_segments == NULL); segment = (Segment *) collect->expected_segments->data; if (compare_segments (segment, event)) { collect->expected_segments = g_list_remove (collect->expected_segments, segment); g_free (segment); } collect->gotsegment = TRUE; sinkpad_buffer_probe (GstPad * sinkpad, GstBuffer * buffer, CollectStructure * collect) fail_if(!collect->gotsegment); new_gnl_src (const gchar * name, guint64 start, gint64 duration, gint priority) GstElement * gnlsource = NULL; gnlsource = gst_element_factory_make_or_warn ("gnlsource", name); fail_if (gnlsource == NULL); g_object_set (G_OBJECT (gnlsource), "start", start, "duration", duration, "media-start", start, "media-duration", duration, "priority", priority, NULL); return gnlsource; videotest_gnl_src (const gchar * name, guint64 start, gint64 duration, gint pattern, guint priority) GstElement * videotestsrc = NULL; videotestsrc = gst_element_factory_make_or_warn ("videotestsrc", NULL); g_object_set (G_OBJECT (videotestsrc), "pattern", pattern, NULL); gnlsource = new_gnl_src (name, start, duration, priority); gst_bin_add (GST_BIN (gnlsource), videotestsrc); videotest_in_bin_gnl_src (const gchar * name, guint64 start, gint64 duration, gint pattern, guint priority) GstElement * bin = NULL; bin = gst_bin_new (NULL); gst_bin_add (GST_BIN (bin), videotestsrc); gst_bin_add (GST_BIN (gnlsource), bin); gst_element_add_pad (bin, gst_ghost_pad_new ("src", gst_element_get_pad (videotestsrc, "src"))); new_operation (const gchar * name, const gchar * factory, guint64 start, gint64 duration, guint priority) GstElement * gnloperation = NULL; GstElement * operation = NULL; operation = gst_element_factory_make_or_warn (factory, NULL); gnloperation = gst_element_factory_make_or_warn ("gnloperation", NULL); g_object_set (G_OBJECT (gnloperation), gst_bin_add (GST_BIN (gnloperation), operation); return gnloperation; static Segment * segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position) segment = g_new0 (Segment, 1); segment->rate = rate; segment->format = format; segment->start = start; segment->stop = stop; segment->position = position; return segment; #define check_start_stop_duration(object, startval, stopval, durval) \ { \ g_object_get (object, "start", &start, "stop", &stop, "duration", &duration, NULL); \ fail_if (start != startval); \ fail_if (stop != stopval); \ fail_if (duration != durval); \ Index: complex.c RCS file: /cvs/gstreamer/gnonlin/tests/check/complex.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- complex.c 19 Jul 2006 12:31:06 -0000 1.6 +++ complex.c 16 Sep 2006 15:40:46 -0000 1.7 @@ -1,180 +1,4 @@ - -#include <gst/check/gstcheck.h> -typedef struct _Segment { - gdouble rate; - GstFormat format; - gint64 start, stop, position; -} Segment; -typedef struct _CollectStructure { - GstElement *comp; - GstElement *sink; - guint64 last_time; - gboolean gotsegment; - GList *expected_segments; -} CollectStructure; -static GstElement * -gst_element_factory_make_or_warn (const gchar * factoryname, const gchar * name) -{ - GstElement * element; - element = gst_element_factory_make (factoryname, name); - fail_unless (element != NULL, "Failed to make element %s", factoryname); - return element; -} -static void -composition_pad_added_cb (GstElement *composition, GstPad *pad, CollectStructure * collect) - fail_if (!(gst_element_link (composition, collect->sink))); -/* return TRUE to discard the Segment */ -static gboolean -compare_segments (Segment * segment, GstEvent * event) - gboolean update; - gdouble rate; - GstFormat format; - gint64 start, stop, position; - gst_event_parse_new_segment (event, &update, &rate, &format, &start, &stop, &position); - GST_DEBUG ("Got NewSegment update:%d, rate:%f, format:%d, start:%"GST_TIME_FORMAT - ", stop:%"GST_TIME_FORMAT", position:%"GST_TIME_FORMAT, - update, rate, format, GST_TIME_ARGS (start), - GST_TIME_ARGS (stop), - GST_TIME_ARGS (position)); - GST_DEBUG ("Expecting rate:%f, format:%d, start:%"GST_TIME_FORMAT - segment->rate, segment->format, - GST_TIME_ARGS (segment->start), - GST_TIME_ARGS (segment->stop), - GST_TIME_ARGS (segment->position)); - if (update) { - GST_DEBUG ("was update, ignoring"); - return FALSE; - } - fail_if (rate != segment->rate); - fail_if (format != segment->format); - fail_if (start != segment->start); - fail_if (stop != segment->stop); - fail_if (position != segment->position); - GST_DEBUG ("Segment was valid, discarding expected Segment"); - return TRUE; -sinkpad_event_probe (GstPad * sinkpad, GstEvent * event, CollectStructure * collect) - Segment * segment; - - if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) { - fail_if (collect->expected_segments == NULL); - segment = (Segment *) collect->expected_segments->data; - if (compare_segments (segment, event)) { - collect->expected_segments = g_list_remove (collect->expected_segments, segment); - g_free (segment); - } - collect->gotsegment = TRUE; -sinkpad_buffer_probe (GstPad * sinkpad, GstBuffer * buffer, CollectStructure * collect) - fail_if(!collect->gotsegment); -videotest_gnl_src (const gchar * name, guint64 start, gint64 duration, gint pattern, guint priority) - GstElement * gnlsource = NULL; - GstElement * videotestsrc = NULL; - videotestsrc = gst_element_factory_make_or_warn ("videotestsrc", NULL); - g_object_set (G_OBJECT (videotestsrc), "pattern", pattern, NULL); - gnlsource = gst_element_factory_make_or_warn ("gnlsource", name); - fail_if (gnlsource == NULL); - g_object_set (G_OBJECT (gnlsource), - "start", start, - "duration", duration, - "media-start", start, - "media-duration", duration, - "priority", priority, - NULL); - gst_bin_add (GST_BIN (gnlsource), videotestsrc); - return gnlsource; -videotest_in_bin_gnl_src (const gchar * name, guint64 start, gint64 duration, gint pattern, guint priority) - GstElement * bin = NULL; - bin = gst_bin_new (NULL); - gst_bin_add (GST_BIN (bin), videotestsrc); - gst_bin_add (GST_BIN (gnlsource), bin); - gst_element_add_pad (bin, gst_ghost_pad_new ("src", gst_element_get_pad (videotestsrc, "src"))); -static Segment * -segment_new (gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position) - segment = g_new0 (Segment, 1); - segment->rate = rate; - segment->format = format; - segment->start = start; - segment->stop = stop; - segment->position = position; - return segment; -#define check_start_stop_duration(object, startval, stopval, durval) \ - { \ - g_object_get (object, "start", &start, "stop", &stop, "duration", &duration, NULL); \ - fail_if (start != startval); \ - fail_if (stop != stopval); \ - fail_if (duration != durval); \ +#include "common.h" GST_START_TEST (test_one_space_another) { --- NEW FILE: gnloperation.c --- #include "common.h" GST_START_TEST (test_simple_operation) GstElement *pipeline; guint64 start, stop; gint64 duration; GstElement *comp, *oper, *source, *sink; CollectStructure *collect; GstBus * bus; GstMessage * message; gboolean carry_on = TRUE; GstPad * sinkpad; pipeline = gst_pipeline_new ("test_pipeline"); comp = gst_element_factory_make_or_warn ("gnlcomposition", "test_composition"); /* source Start : 0s Duration : 3s Priority : 1 */ source = videotest_gnl_src ("source", 0, 3 * GST_SECOND, 1 , 1); fail_if (source == NULL); check_start_stop_duration (source, 0, 3 * GST_SECOND, 3 * GST_SECOND); operation Start : 1s Duration : 1s Priority : 0 oper = new_operation ("oper", "identity", 1 * GST_SECOND, 1 * GST_SECOND, 0); fail_if (oper == NULL); check_start_stop_duration (oper, 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND); /* Add source */ ASSERT_OBJECT_REFCOUNT(source, "source", 1); ASSERT_OBJECT_REFCOUNT(oper, "oper", 1); gst_bin_add (GST_BIN (comp), source); check_start_stop_duration(comp, 0, 3 * GST_SECOND, 3 * GST_SECOND); /* Add operaton */ gst_bin_add (GST_BIN (comp), oper); /* remove source */ gst_object_ref (source); gst_bin_remove (GST_BIN (comp), source); check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND); /* re-add source */ gst_object_unref (source); sink = gst_element_factory_make_or_warn ("fakesink", "sink"); gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL); /* Shared data */ collect = g_new0 (CollectStructure, 1); collect->comp = comp; collect->sink = sink; /* Expected segments */ collect->expected_segments = g_list_append (collect->expected_segments, segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0)); 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND)); 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND)); g_signal_connect (G_OBJECT (comp), "pad-added", G_CALLBACK (composition_pad_added_cb), collect); sinkpad = gst_element_get_pad (sink, "sink"); gst_pad_add_event_probe (sinkpad, G_CALLBACK (sinkpad_event_probe), collect); gst_pad_add_buffer_probe (sinkpad, G_CALLBACK (sinkpad_buffer_probe), collect); bus = gst_element_get_bus (GST_ELEMENT (pipeline)); GST_DEBUG ("Setting pipeline to PLAYING"); fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE); GST_DEBUG ("Let's poll the bus"); while (carry_on) { message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 2); if (message) { switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_EOS: /* we should check if we really finished here */ GST_WARNING ("Got an EOS"); carry_on = FALSE; break; case GST_MESSAGE_SEGMENT_START: case GST_MESSAGE_SEGMENT_DONE: /* We shouldn't see any segement messages, since we didn't do a segment seek */ GST_WARNING ("Saw a Segment start/stop"); fail_if (TRUE); case GST_MESSAGE_ERROR: GST_WARNING ("Saw an ERROR"); default: } gst_mini_object_unref (GST_MINI_OBJECT (message)); GST_DEBUG ("Setting pipeline to NULL"); fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY) == GST_STATE_CHANGE_FAILURE); fail_if (collect->expected_segments != NULL); GST_DEBUG ("Resetted pipeline to READY"); 1 * GST_SECOND)); 2 * GST_SECOND)); collect->gotsegment = FALSE; GST_DEBUG ("Setting pipeline to PLAYING again"); carry_on = TRUE; GST_ERROR ("Saw an ERROR"); } else { GST_DEBUG ("bus_poll responded, but there wasn't any message..."); fail_if (gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE); gst_object_unref (GST_OBJECT(sinkpad)); ASSERT_OBJECT_REFCOUNT_BETWEEN(pipeline, "main pipeline", 1, 2); gst_object_unref (pipeline); ASSERT_OBJECT_REFCOUNT_BETWEEN(bus, "main bus", 1, 2); gst_object_unref (bus); g_free (collect); GST_END_TEST; Suite * gnonlin_suite (void) Suite *s = suite_create ("gnonlin"); TCase *tc_chain = tcase_create ("gnloperation"); guint major, minor, micro, nano; suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_simple_operation); return s; int main (int argc, char **argv) int nf; Suite *s = gnonlin_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; Index: gnlsource.c RCS file: /cvs/gstreamer/gnonlin/tests/check/gnlsource.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gnlsource.c 19 Jul 2006 12:31:06 -0000 1.4 +++ gnlsource.c 16 Sep 2006 15:40:46 -0000 1.5 @@ -1,183 +1,4 @@ - GstElement *source; -gnlsource_pad_added_cb (GstElement *gnlsource, GstPad *pad, GstElement *sink) - GST_DEBUG_OBJECT (gnlsource, "About to link to sink"); - fail_if (!(gst_element_link (gnlsource, sink))); - GST_DEBUG_OBJECT (gnlsource, "Linked to sink"); - GST_DEBUG ("Got new event"); GST_START_TEST (test_simple_videotestsrc) @@ -210,7 +31,7 @@ /* Shared data */ collect = g_new0 (CollectStructure, 1); - collect->source = gnlsource; + collect->comp = gnlsource; collect->sink = sink; /* Expected segments */ @@ -219,8 +40,8 @@ 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND)); g_signal_connect (G_OBJECT (gnlsource), "pad-added", - G_CALLBACK (gnlsource_pad_added_cb), - sink); + G_CALLBACK (composition_pad_added_cb), + collect); sinkpad = gst_element_get_pad (sink, "sink"); fail_if (sinkpad == NULL); @@ -311,7 +132,7 @@ @@ -320,8 +141,8 @@ 0, 1 * GST_SECOND, 0)); Index: simple.c RCS file: /cvs/gstreamer/gnonlin/tests/check/simple.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- simple.c 19 Jul 2006 12:31:06 -0000 1.15 +++ simple.c 16 Sep 2006 15:40:46 -0000 1.16 GST_START_TEST (test_time_duration) |