tests: appsrc: Fix test on Windows

Windows does not support fork() so all tests will run in a single
process, and global variables will be reused across multiple tests.
Thus, each test should reset global variables.

Also, setup pad chain/event functions before playing state

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5752>
This commit is contained in:
Seungha Yang 2023-12-02 00:49:47 +09:00 committed by GStreamer Marge Bot
parent 96cf1f8c8e
commit 36529475ae

View file

@ -1428,12 +1428,13 @@ GST_START_TEST (test_appsrc_send_custom_event)
src = setup_appsrc ();
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
expect_offset = 0;
done = FALSE;
gst_pad_set_chain_function (mysinkpad, send_event_chain_func);
gst_pad_set_event_function (mysinkpad, send_event_event_func);
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
/* send a buffer, a custom event and a second buffer */
buf = gst_buffer_new_and_alloc (1);
GST_BUFFER_OFFSET (buf) = 0;
@ -1526,12 +1527,13 @@ GST_START_TEST (test_appsrc_send_event_before_buffer)
src = setup_appsrc ();
g_object_set (src, "format", GST_FORMAT_TIME, NULL);
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
expected_obj = EXPECTED_STREAM_START;
done = FALSE;
gst_pad_set_event_function (mysinkpad, send_event_before_buffer_event_func);
gst_pad_set_chain_function (mysinkpad, send_event_before_buffer_chain_func);
expected_obj = EXPECTED_STREAM_START;
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
/* send a custom event and then the first buffer */
gst_element_send_event (src,
@ -1570,12 +1572,13 @@ GST_START_TEST (test_appsrc_send_event_before_sample)
src = setup_appsrc ();
g_object_set (src, "format", GST_FORMAT_TIME, NULL);
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
expected_obj = EXPECTED_STREAM_START;
done = FALSE;
gst_pad_set_event_function (mysinkpad, send_event_before_buffer_event_func);
gst_pad_set_chain_function (mysinkpad, send_event_before_buffer_chain_func);
expected_obj = EXPECTED_STREAM_START;
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
/* send a custom event and then the first sample */
gst_element_send_event (src,
@ -1616,12 +1619,13 @@ GST_START_TEST (test_appsrc_send_event_between_caps_buffer)
src = setup_appsrc ();
g_object_set (src, "format", GST_FORMAT_TIME, NULL);
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
expected_obj = EXPECTED_STREAM_START;
done = FALSE;
gst_pad_set_event_function (mysinkpad, send_event_before_buffer_event_func);
gst_pad_set_chain_function (mysinkpad, send_event_before_buffer_chain_func);
expected_obj = EXPECTED_STREAM_START;
ASSERT_SET_STATE (src, GST_STATE_PLAYING, GST_STATE_CHANGE_SUCCESS);
caps = gst_caps_from_string ("video/x-raw");
gst_app_src_set_caps (GST_APP_SRC_CAST (src), caps);