From: Matthew Waters Date: Wed, 6 May 2020 05:35:26 +0000 (+1000) Subject: webrtc: fix a slightly racy test X-Git-Tag: 1.19.3~507^2~1918 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0b20f8bbaa9e5611258045102ae45c9d6d45d6e;p=platform%2Fupstream%2Fgstreamer.git webrtc: fix a slightly racy test There is no guarantee that the peer data channel has transitioned to open when we do. Part-of: --- diff --git a/tests/check/elements/webrtcbin.c b/tests/check/elements/webrtcbin.c index e43a4ff..eeb733d 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);