scenario: Check that all action were properly executed
authorThibault Saunier <thibault.saunier@collabora.com>
Sat, 28 Sep 2013 00:18:55 +0000 (02:18 +0200)
committerThibault Saunier <thibault.saunier@collabora.com>
Sat, 5 Oct 2013 16:36:04 +0000 (13:36 -0300)
validate/gst/validate/gst-validate-report.c
validate/gst/validate/gst-validate-report.h
validate/gst/validate/gst-validate-scenario.c

index 6cc07a4fc6a64e84902a26098d9d6fb020ee9b0b..74b8c4e7890eea24372233b04bd29d4683dd95cd 100644 (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";
index c421068e2f039b1734dc0fbb2532b27d5fbbc644..b4c4dba53c64c5a08b578b0c768b5493a03799b6 100644 (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 {
index 8eba3d522321c6f818483a5b19ecf701cf350856..d11d458d0cc52654515bca5e431ccb3c694d3287 100644 (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);