diff options
author | Matthew Waters <matthew@centricular.com> | 2020-05-06 15:35:26 +1000 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2020-05-06 15:49:58 +1000 |
commit | d0b20f8bbaa9e5611258045102ae45c9d6d45d6e (patch) | |
tree | f04dba8659a8b96e2b58acbab6b15f4b44410405 /tests | |
parent | 18de5f8f04c7aa9873190ea2c44eb01209e3de6e (diff) | |
download | gstreamer-plugins-bad-d0b20f8bbaa9e5611258045102ae45c9d6d45d6e.tar.gz |
webrtc: fix a slightly racy test
There is no guarantee that the peer data channel has transitioned to
open when we do.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1247>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/check/elements/webrtcbin.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/check/elements/webrtcbin.c b/tests/check/elements/webrtcbin.c index e43a4ff15..eeb733d95 100644 --- a/tests/check/elements/webrtcbin.c +++ b/tests/check/elements/webrtcbin.c @@ -1629,7 +1629,13 @@ static const gchar *test_string = "GStreamer WebRTC is awesome!"; static void on_message_string (GObject * channel, const gchar * str, struct test_webrtc *t) { - gchar *expected = g_object_steal_data (channel, "expected"); + GstWebRTCDataChannelState state; + gchar *expected; + + g_object_get (channel, "ready-state", &state, NULL); + fail_unless_equals_int (GST_WEBRTC_DATA_CHANNEL_STATE_OPEN, state); + + expected = g_object_steal_data (channel, "expected"); g_assert_cmpstr (expected, ==, str); g_free (expected); @@ -1645,8 +1651,6 @@ have_data_channel_transfer_string (struct test_webrtc *t, GstElement * element, g_object_get (our, "ready-state", &state, NULL); fail_unless_equals_int (GST_WEBRTC_DATA_CHANNEL_STATE_OPEN, state); - g_object_get (other, "ready-state", &state, NULL); - fail_unless_equals_int (GST_WEBRTC_DATA_CHANNEL_STATE_OPEN, state); g_object_set_data_full (our, "expected", g_strdup (test_string), g_free); g_signal_connect (our, "on-message-string", G_CALLBACK (on_message_string), @@ -1704,7 +1708,13 @@ GST_END_TEST; static void on_message_data (GObject * channel, GBytes * data, struct test_webrtc *t) { - GBytes *expected = g_object_steal_data (channel, "expected"); + GstWebRTCDataChannelState state; + GBytes *expected; + + g_object_get (channel, "ready-state", &state, NULL); + fail_unless_equals_int (GST_WEBRTC_DATA_CHANNEL_STATE_OPEN, state); + + expected = g_object_steal_data (channel, "expected"); g_assert_cmpbytes (data, expected); g_bytes_unref (expected); @@ -1721,8 +1731,6 @@ have_data_channel_transfer_data (struct test_webrtc *t, GstElement * element, g_object_get (our, "ready-state", &state, NULL); fail_unless_equals_int (GST_WEBRTC_DATA_CHANNEL_STATE_OPEN, state); - g_object_get (other, "ready-state", &state, NULL); - fail_unless_equals_int (GST_WEBRTC_DATA_CHANNEL_STATE_OPEN, state); g_object_set_data_full (our, "expected", g_bytes_ref (data), (GDestroyNotify) g_bytes_unref); |