tests: Test reports refcounts.

+ Set the element monitor on the element as qdata.
This commit is contained in:
Mathieu Duponchelle 2014-10-10 02:49:54 +02:00 committed by Mathieu Duponchelle
parent c943a75766
commit de554ba417
4 changed files with 43 additions and 0 deletions

View file

@ -161,6 +161,14 @@ gst_validate_element_monitor_do_setup (GstValidateMonitor * monitor)
GST_VALIDATE_MONITOR_GET_OBJECT (monitor)); GST_VALIDATE_MONITOR_GET_OBJECT (monitor));
element = GST_VALIDATE_ELEMENT_MONITOR_GET_ELEMENT (monitor); element = GST_VALIDATE_ELEMENT_MONITOR_GET_ELEMENT (monitor);
if (g_object_get_data ((GObject *) element, "validate-monitor")) {
GST_WARNING_OBJECT (elem_monitor,
"Pad already has a validate-monitor associated");
return FALSE;
}
g_object_set_data ((GObject *) element, "validate-monitor", elem_monitor);
gst_validate_element_monitor_inspect (elem_monitor); gst_validate_element_monitor_inspect (elem_monitor);
elem_monitor->pad_added_id = g_signal_connect (element, "pad-added", elem_monitor->pad_added_id = g_signal_connect (element, "pad-added",

View file

@ -22,6 +22,22 @@
#include <gst/check/gstcheck.h> #include <gst/check/gstcheck.h>
#include "test-utils.h" #include "test-utils.h"
static void
_check_reports_refcount (GstPad *pad, gint refcount)
{
GList *tmp, *reports;
GstValidateReporter *reporter = (GstValidateReporter *) g_object_get_data (G_OBJECT (pad), "validate-monitor");
reports = gst_validate_reporter_get_reports (reporter);
/* We take a ref here */
refcount += 1;
for (tmp = reports; tmp; tmp = tmp->next)
fail_unless_equals_int (((GstValidateReport *) tmp->data)->refcount, refcount);
g_list_free_full (reports, (GDestroyNotify )gst_validate_report_unref);
}
GST_START_TEST (buffer_before_segment) GST_START_TEST (buffer_before_segment)
{ {
GstPad *srcpad; GstPad *srcpad;
@ -81,6 +97,7 @@ GST_START_TEST (buffer_before_segment)
fail_unless_equals_int (gst_element_set_state (sink, GST_STATE_NULL), fail_unless_equals_int (gst_element_set_state (sink, GST_STATE_NULL),
GST_STATE_CHANGE_SUCCESS); GST_STATE_CHANGE_SUCCESS);
_check_reports_refcount (srcpad, 2);
gst_object_unref (srcpad); gst_object_unref (srcpad);
check_destroyed (src, srcpad, NULL); check_destroyed (src, srcpad, NULL);
check_destroyed (sink, NULL, NULL); check_destroyed (sink, NULL, NULL);
@ -504,6 +521,14 @@ GST_START_TEST (issue_concatenation)
gst_pad_remove_probe (srcpad1, probe_id1); gst_pad_remove_probe (srcpad1, probe_id1);
gst_pad_remove_probe (srcpad2, probe_id2); gst_pad_remove_probe (srcpad2, probe_id2);
/* The reporter, the runner */
_check_reports_refcount (srcpad1, 2);
/* The reporter, the master report */
_check_reports_refcount (funnel_sink1, 2);
free_element_monitor (src1);
free_element_monitor (src2);
free_element_monitor (funnel);
free_element_monitor (sink);
gst_object_unref (srcpad1); gst_object_unref (srcpad1);
gst_object_unref (srcpad2); gst_object_unref (srcpad2);
gst_object_unref (sinkpad); gst_object_unref (sinkpad);

View file

@ -213,3 +213,12 @@ GstElement * create_and_monitor_element (const gchar *factoryname, const gchar *
return element; return element;
} }
void
free_element_monitor (GstElement *element)
{
GstValidateMonitor *monitor;
monitor = (GstValidateMonitor *) g_object_get_data (G_OBJECT (element), "validate-monitor");
g_object_unref (G_OBJECT(monitor));
}

View file

@ -32,6 +32,7 @@ GstValidateRunner * setup_runner (GstObject * object);
void clean_bus (GstElement *element); void clean_bus (GstElement *element);
GstValidatePadMonitor * get_pad_monitor (GstPad *pad); GstValidatePadMonitor * get_pad_monitor (GstPad *pad);
GstElement * create_and_monitor_element (const gchar *factoryname, const gchar *name, GstValidateRunner *runner); GstElement * create_and_monitor_element (const gchar *factoryname, const gchar *name, GstValidateRunner *runner);
void free_element_monitor (GstElement *element);
typedef struct { typedef struct {
GstElement parent; GstElement parent;