+/* parser_pull_frame_growth test */
+
+/* Buffer size is chosen to interact with
+ * the 64KB that baseparse reads
+ * from upstream as cache size */
+#define BUFSIZE (123 * 1024)
+
+static GstFlowReturn
+_sink_chain_pull_frame_growth (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer)
+{
+ gst_buffer_unref (buffer);
+
+ have_data = TRUE;
+ buffer_count++;
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+_src_getrange_64k (GstPad * pad, GstObject * parent, guint64 offset,
+ guint length, GstBuffer ** buffer)
+{
+ guint8 *data;
+
+ /* Our "file" is large enough for 4 packets exactly */
+ if (offset >= BUFSIZE * 4)
+ return GST_FLOW_EOS;
+
+ /* Return a buffer of the size baseparse asked for */
+ data = g_malloc0 (length);
+ *buffer = gst_buffer_new_wrapped (data, length);
+
+ return GST_FLOW_OK;
+}
+
+/* Test that when we fail to parse a frame from
+ * the provided data, that baseparse provides a larger
+ * buffer on the next iteration */
+GST_START_TEST (parser_pull_frame_growth)
+{
+ have_eos = FALSE;
+ have_data = FALSE;
+ loop = g_main_loop_new (NULL, FALSE);
+
+ setup_parsertester ();
+ buffer_count = 0;
+
+ /* This size is chosen to require that baseparse pull
+ * a 2nd 64KB buffer */
+ ((GstParserTester *) (parsetest))->min_frame_size = BUFSIZE;
+
+ gst_pad_set_getrange_function (mysrcpad, _src_getrange_64k);
+ gst_pad_set_query_function (mysrcpad, _src_query);
+ gst_pad_set_chain_function (mysinkpad, _sink_chain_pull_frame_growth);
+ gst_pad_set_event_function (mysinkpad, _sink_event);
+ gst_base_parse_set_min_frame_size (GST_BASE_PARSE (parsetest), 1024);
+
+ gst_pad_set_active (mysrcpad, TRUE);
+ gst_element_set_state (parsetest, GST_STATE_PLAYING);
+ gst_pad_set_active (mysinkpad, TRUE);
+
+ g_main_loop_run (loop);
+ fail_unless (have_eos == TRUE);
+ fail_unless (have_data == TRUE);
+
+ gst_element_set_state (parsetest, GST_STATE_NULL);
+
+ check_no_error_received ();
+ cleanup_parsertest ();
+
+ g_main_loop_unref (loop);
+ loop = NULL;
+}
+
+GST_END_TEST;
+
+