webrtcstats: Update unit test for outbound rtp stats
authorSherrill Lin <lshuying@amazon.com>
Wed, 1 Sep 2021 16:12:24 +0000 (16:12 +0000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 26 May 2022 10:54:59 +0000 (10:54 +0000)
"remote-id" is not guaranteed to present after commit 1deb034e3d873f577a38bc483e6256b0346ee874.
Thus, we should not fail the test if "remote-id" is not found.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>

subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c

index e518a3b..16abe97 100644 (file)
@@ -1528,14 +1528,14 @@ validate_outbound_rtp_stats (const GstStructure * s, const GstStructure * stats)
           &packets_sent, NULL));
   fail_unless (gst_structure_get (s, "bytes-sent", G_TYPE_UINT64, &bytes_sent,
           NULL));
-  fail_unless (gst_structure_get (s, "remote-id", G_TYPE_STRING, &remote_id,
-          NULL));
-  fail_unless (gst_structure_get (stats, remote_id, GST_TYPE_STRUCTURE, &remote,
-          NULL));
-  fail_unless (remote != NULL);
+  if (gst_structure_get (s, "remote-id", G_TYPE_STRING, &remote_id, NULL)) {
+    fail_unless (gst_structure_get (stats, remote_id, GST_TYPE_STRUCTURE,
+            &remote, NULL));
+    fail_unless (remote != NULL);
 
-  gst_structure_free (remote);
-  g_free (remote_id);
+    gst_structure_free (remote);
+    g_free (remote_id);
+  }
 }
 
 static void
@@ -1703,7 +1703,7 @@ GST_START_TEST (test_stats_with_stream)
   gst_caps_unref (caps);
 
   test_webrtc_wait_for_answer_error_eos (t);
-  fail_unless (t->state == STATE_ANSWER_SET);
+  test_webrtc_signal_state (t, STATE_ANSWER_SET);
 
   p = gst_promise_new_with_change_func (_on_stats, t, NULL);
   g_signal_emit_by_name (t->webrtc1, "get-stats", NULL, p);