mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
tests: Check monitors correctly determine their reporting level.
+ [API] gst_validate_reporter_get_reporting_level
This commit is contained in:
parent
5cb60060dc
commit
0a1cdb2164
4 changed files with 83 additions and 0 deletions
|
@ -63,10 +63,16 @@ gst_validate_monitor_intercept_report (GstValidateReporter * reporter,
|
|||
#define _do_init \
|
||||
G_IMPLEMENT_INTERFACE (GST_TYPE_VALIDATE_REPORTER, _reporter_iface_init)
|
||||
|
||||
static GstValidateReportingLevel
|
||||
_get_reporting_level (GstValidateReporter *monitor)
|
||||
{
|
||||
return GST_VALIDATE_MONITOR (monitor)->level;
|
||||
}
|
||||
static void
|
||||
_reporter_iface_init (GstValidateReporterInterface * iface)
|
||||
{
|
||||
iface->intercept_report = gst_validate_monitor_intercept_report;
|
||||
iface->get_reporting_level = _get_reporting_level;
|
||||
}
|
||||
|
||||
#define gst_validate_monitor_parent_class parent_class
|
||||
|
|
|
@ -113,6 +113,20 @@ gst_validate_reporter_intercept_report (GstValidateReporter * reporter,
|
|||
return ret;
|
||||
}
|
||||
|
||||
GstValidateReportingLevel
|
||||
gst_validate_reporter_get_reporting_level (GstValidateReporter * reporter)
|
||||
{
|
||||
GstValidateInterceptionReturn ret = GST_VALIDATE_REPORTING_LEVEL_UNKNOWN;
|
||||
GstValidateReporterInterface *iface =
|
||||
GST_VALIDATE_REPORTER_GET_INTERFACE (reporter);
|
||||
|
||||
if (iface->get_reporting_level) {
|
||||
ret = iface->get_reporting_level (reporter);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
GstValidateReport *
|
||||
gst_validate_reporter_get_report (GstValidateReporter * reporter,
|
||||
GstValidateIssueId issue_id)
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef struct _GstValidateReporterInterface GstValidateReporterInterface;
|
|||
#include <glib-object.h>
|
||||
#include <gst/validate/gst-validate-report.h>
|
||||
#include <gst/validate/gst-validate-runner.h>
|
||||
#include <gst/validate/gst-validate-enums.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -80,6 +81,8 @@ struct _GstValidateReporterInterface
|
|||
|
||||
GstValidateInterceptionReturn (*intercept_report) (GstValidateReporter *
|
||||
reporter, GstValidateReport * report);
|
||||
GstValidateReportingLevel (*get_reporting_level) (GstValidateReporter *
|
||||
reporter);
|
||||
};
|
||||
|
||||
void gst_validate_reporter_set_name (GstValidateReporter * reporter,
|
||||
|
@ -98,6 +101,7 @@ GstValidateReport * gst_validate_reporter_get_report (GstValidateReporter *repor
|
|||
GstValidateIssueId issue_id);
|
||||
GList * gst_validate_reporter_get_reports (GstValidateReporter * reporter);
|
||||
gint gst_validate_reporter_get_reports_count (GstValidateReporter *reporter);
|
||||
GstValidateReportingLevel gst_validate_reporter_get_reporting_level (GstValidateReporter *reporter);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* _GST_VALIDATE_REPORTER_ */
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
GST_START_TEST (test_report_levels)
|
||||
{
|
||||
GstValidateRunner *runner;
|
||||
GstObject *pipeline;
|
||||
GError *error = NULL;
|
||||
GstElement *element;
|
||||
GstValidateMonitor *monitor, *pipeline_monitor;
|
||||
GstPad *pad;
|
||||
|
||||
/* FIXME: for now the only interface to set the reporting level is through an
|
||||
* environment variable parsed at the time of the runner initialization,
|
||||
|
@ -56,6 +61,60 @@ GST_START_TEST (test_report_levels)
|
|||
"other_test_object") == GST_VALIDATE_REPORTING_LEVEL_ALL);
|
||||
fail_unless (gst_validate_runner_get_reporting_level_for_name (runner,
|
||||
"dummy_test_object") == GST_VALIDATE_REPORTING_LEVEL_UNKNOWN);
|
||||
|
||||
g_object_unref (runner);
|
||||
|
||||
/* Now let's try to see if the created monitors actually understand the
|
||||
* situation they've put themselves into */
|
||||
fail_unless (g_setenv ("GST_VALIDATE_REPORT_LEVEL",
|
||||
"none,pipeline*:monitor,sofake1:all,sofake*::sink:subchain", TRUE));
|
||||
runner = gst_validate_runner_new ();
|
||||
|
||||
pipeline = (GstObject *)
|
||||
gst_parse_launch ("fakesrc name=sofake1 ! fakesink name=sofake2", &error);
|
||||
fail_unless (pipeline != NULL);
|
||||
pipeline_monitor =
|
||||
gst_validate_monitor_factory_create (GST_OBJECT (pipeline), runner, NULL);
|
||||
|
||||
element = gst_bin_get_by_name (GST_BIN (pipeline), "sofake1");
|
||||
monitor =
|
||||
(GstValidateMonitor *) g_object_get_data (G_OBJECT (element),
|
||||
"validate-monitor");
|
||||
fail_unless (gst_validate_reporter_get_reporting_level (GST_VALIDATE_REPORTER
|
||||
(monitor)) == GST_VALIDATE_REPORTING_LEVEL_ALL);
|
||||
|
||||
pad = gst_element_get_static_pad (element, "src");
|
||||
monitor =
|
||||
(GstValidateMonitor *) g_object_get_data (G_OBJECT (pad),
|
||||
"validate-monitor");
|
||||
/* The pad should have inherited the reporting level */
|
||||
fail_unless (gst_validate_reporter_get_reporting_level (GST_VALIDATE_REPORTER
|
||||
(monitor)) == GST_VALIDATE_REPORTING_LEVEL_ALL);
|
||||
gst_object_unref (pad);
|
||||
|
||||
gst_object_unref (element);
|
||||
|
||||
element = gst_bin_get_by_name (GST_BIN (pipeline), "sofake2");
|
||||
monitor =
|
||||
(GstValidateMonitor *) g_object_get_data (G_OBJECT (element),
|
||||
"validate-monitor");
|
||||
/* The element should have inherited its reporting level from the pipeline */
|
||||
fail_unless (gst_validate_reporter_get_reporting_level (GST_VALIDATE_REPORTER
|
||||
(monitor)) == GST_VALIDATE_REPORTING_LEVEL_MONITOR);
|
||||
|
||||
pad = gst_element_get_static_pad (element, "sink");
|
||||
monitor =
|
||||
(GstValidateMonitor *) g_object_get_data (G_OBJECT (pad),
|
||||
"validate-monitor");
|
||||
/* But its pad should not as it falls in the sofake*::sink pattern */
|
||||
fail_unless (gst_validate_reporter_get_reporting_level (GST_VALIDATE_REPORTER
|
||||
(monitor)) == GST_VALIDATE_REPORTING_LEVEL_SUBCHAIN);
|
||||
gst_object_unref (pad);
|
||||
|
||||
gst_object_unref (element);
|
||||
|
||||
g_object_unref (pipeline_monitor);
|
||||
gst_object_unref (pipeline);
|
||||
g_object_unref (runner);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue