scenario: Check that all action were properly executed

This commit is contained in:
Thibault Saunier 2013-09-28 02:18:55 +02:00
parent c9ee576e8e
commit e24645b133
3 changed files with 45 additions and 9 deletions

View file

@ -207,6 +207,9 @@ gst_validate_report_load_issues (void)
REGISTER_VALIDATE_ISSUE (WARNING, QUERY_POSITION_OUT_OF_SEGMENT,
_("Query position reported a value outside of the current expected "
"segment"), NULL);
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_NOT_ENDED,
_("All the actions were not executed before the program stoped"),
NULL);
}
void
@ -278,6 +281,8 @@ gst_validate_report_area_get_name (GstValidateReportArea area)
return "run-error";
case GST_VALIDATE_AREA_OTHER:
return "other";
case GST_VALIDATE_AREA_SCENARIO:
return "scenario";
default:
g_assert_not_reached ();
return "unknown";

View file

@ -58,6 +58,7 @@ typedef enum {
GST_VALIDATE_AREA_SEEK,
GST_VALIDATE_AREA_STATE,
GST_VALIDATE_AREA_FILE_CHECK,
GST_VALIDATE_AREA_SCENARIO,
GST_VALIDATE_AREA_RUN_ERROR,
GST_VALIDATE_AREA_OTHER=100,
} GstValidateReportArea;
@ -109,6 +110,8 @@ typedef enum {
#define GST_VALIDATE_ISSUE_ID_QUERY_POSITION_SUPERIOR_DURATION (((GstValidateIssueId) GST_VALIDATE_AREA_QUERY) << GST_VALIDATE_ISSUE_ID_SHIFT | 1)
#define GST_VALIDATE_ISSUE_ID_QUERY_POSITION_OUT_OF_SEGMENT (((GstValidateIssueId) GST_VALIDATE_AREA_QUERY) << GST_VALIDATE_ISSUE_ID_SHIFT | 2)
#define GST_VALIDATE_ISSUE_ID_SCENARIO_NOT_ENDED (((GstValidateIssueId) GST_VALIDATE_AREA_SCENARIO) << GST_VALIDATE_ISSUE_ID_SHIFT | 1)
#define GST_VALIDATE_ISSUE_ID_AREA(id) ((guintptr)(id >> GST_VALIDATE_ISSUE_ID_SHIFT))
typedef struct {

View file

@ -597,19 +597,47 @@ gst_validate_scenario_update_segment_from_seek (GstValidateScenario * scenario,
}
static gboolean
async_done_cb (GstBus * bus, GstMessage * message,
message_cb (GstBus * bus, GstMessage * message,
GstValidateScenario * scenario)
{
GstValidateScenarioPrivate *priv = scenario->priv;
if (priv->last_seek) {
gst_validate_scenario_update_segment_from_seek (scenario, priv->last_seek);
gst_event_replace (&priv->last_seek, NULL);
}
switch (GST_MESSAGE_TYPE (message))
{
case GST_MESSAGE_ASYNC_DONE:
if (priv->last_seek) {
gst_validate_scenario_update_segment_from_seek (scenario, priv->last_seek);
gst_event_replace (&priv->last_seek, NULL);
}
if (priv->get_pos_id == 0) {
get_position (scenario);
priv->get_pos_id = g_timeout_add (50, (GSourceFunc) get_position, scenario);
if (priv->get_pos_id == 0) {
get_position (scenario);
priv->get_pos_id = g_timeout_add (50, (GSourceFunc) get_position, scenario);
}
break;
case GST_MESSAGE_ERROR:
case GST_MESSAGE_EOS:
{
if (scenario->priv->actions) {
GList *tmp;
gchar *actions = g_strdup (""), *tmpconcat;
for (tmp = scenario->priv->actions; tmp; tmp = tmp->next) {
GstValidateAction *action = ((GstValidateAction*) tmp->data);
tmpconcat = actions;
actions = g_strdup_printf ("%s\n%*s%s",
actions, 20, "", gst_structure_to_string (action->structure));
g_free (tmpconcat);
}
GST_VALIDATE_REPORT (scenario, SCENARIO_NOT_ENDED,
"The following action were not executed: %s", actions);
g_free (actions);
}
}
default:
break;
}
return TRUE;
@ -873,7 +901,7 @@ gst_validate_scenario_factory_create (GstValidateRunner * runner,
bus = gst_element_get_bus (pipeline);
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::async-done", (GCallback) async_done_cb,
g_signal_connect (bus, "message", (GCallback) message_cb,
scenario);
gst_object_unref (bus);