validate: Test buffer outside of received range.
authorMathieu Duponchelle <mathieu.duponchelle@opencreed.com>
Thu, 22 Jan 2015 21:29:10 +0000 (22:29 +0100)
committerMathieu Duponchelle <mathieu.duponchelle@opencreed.com>
Thu, 19 Feb 2015 11:19:46 +0000 (12:19 +0100)
Summary: As part of the preparation for a port to tracer.

Test Plan: This is a test, we won't test tests

Reviewers: tsaunier

Differential Revision: http://internal.opencreed.com:8888/D19

validate/tests/check/validate/padmonitor.c

index 15241d7..b395ec1 100644 (file)
@@ -907,6 +907,74 @@ GST_START_TEST (eos_without_segment)
 
 GST_END_TEST;
 
+GST_START_TEST (buffer_timestamp_out_of_received_range)
+{
+  GstPad *srcpad, *sinkpad;
+  GstElement *decoder = fake_decoder_new ();
+  GstElement *sink = gst_element_factory_make ("fakesink", NULL);
+  GstBin *pipeline = GST_BIN (gst_pipeline_new ("validate-pipeline"));
+  GList *reports;
+  GstValidateRunner *runner;
+  GstSegment segment;
+  GstBuffer *buffer;
+  GstPad *decoder_srcpad;
+  GstValidateReport *report;
+
+  fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE));
+  runner = _start_monitoring_bin (pipeline);
+
+  gst_bin_add_many (pipeline, decoder, sink, NULL);
+  srcpad = gst_pad_new ("srcpad1", GST_PAD_SRC);
+  sinkpad = decoder->sinkpads->data;
+  gst_pad_link (srcpad, sinkpad);
+
+  gst_element_link (decoder, sink);
+  ASSERT_SET_STATE (GST_ELEMENT (pipeline), GST_STATE_PLAYING,
+      GST_STATE_CHANGE_ASYNC);
+  fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE));
+
+  gst_segment_init (&segment, GST_FORMAT_TIME);
+  segment.start = 0;
+  segment.stop = GST_SECOND;
+  fail_unless (gst_pad_push_event (srcpad,
+          gst_event_new_stream_start ("the-stream")));
+  fail_unless (gst_pad_push_event (srcpad, gst_event_new_segment (&segment)));
+
+  {
+    buffer = gst_buffer_new ();
+    GST_BUFFER_PTS (buffer) = 0 * GST_SECOND;
+    GST_BUFFER_DURATION (buffer) = 0.1 * GST_SECOND;
+    fail_unless (gst_pad_push (srcpad, buffer) == GST_FLOW_OK);
+  }
+
+  decoder_srcpad = gst_element_get_static_pad (decoder, "src");
+
+  {
+    buffer = gst_buffer_new ();
+    GST_BUFFER_PTS (buffer) = 0.9 * GST_SECOND;
+    GST_BUFFER_DURATION (buffer) = 0.1 * GST_SECOND;
+    fail_unless (gst_pad_push (decoder_srcpad, buffer) == GST_FLOW_OK);
+  }
+
+  reports = gst_validate_runner_get_reports (runner);
+
+  assert_equals_int (g_list_length (reports), 1);
+  report = reports->data;
+  fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_WARNING);
+  fail_unless_equals_int (report->issue->issue_id,
+      BUFFER_TIMESTAMP_OUT_OF_RECEIVED_RANGE);
+  g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref);
+
+  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+
+  gst_object_unref (decoder_srcpad);
+  gst_object_unref (srcpad);
+
+  _stop_monitoring_bin (pipeline, runner);
+}
+
+GST_END_TEST;
+
 static Suite *
 gst_validate_suite (void)
 {
@@ -918,6 +986,7 @@ gst_validate_suite (void)
 
   tcase_add_test (tc_chain, buffer_before_segment);
   tcase_add_test (tc_chain, buffer_outside_segment);
+  tcase_add_test (tc_chain, buffer_timestamp_out_of_received_range);
   tcase_add_test (tc_chain, flow_aggregation);
   tcase_add_test (tc_chain, issue_concatenation);
   tcase_add_test (tc_chain, check_media_info);