Use callback version of AddIceCandidate in PC tests

Bug: webrtc:11798
Change-Id: I50919e744d24b47ffac8ba294e18a31dfa053a50
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261245
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36835}
diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h
index 24d4616..f408e0c 100644
--- a/pc/test/integration_test_helpers.h
+++ b/pc/test/integration_test_helpers.h
@@ -27,6 +27,7 @@
 #include <vector>
 
 #include "absl/algorithm/container.h"
+#include "absl/memory/memory.h"
 #include "absl/types/optional.h"
 #include "api/audio_options.h"
 #include "api/call/call_factory_interface.h"
@@ -1045,9 +1046,12 @@
                          int sdp_mline_index,
                          const std::string& msg) override {
     RTC_LOG(LS_INFO) << debug_name_ << ": ReceiveIceMessage";
-    std::unique_ptr<webrtc::IceCandidateInterface> candidate(
-        webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, msg, nullptr));
-    EXPECT_TRUE(pc()->AddIceCandidate(candidate.get()));
+    absl::optional<RTCError> result;
+    pc()->AddIceCandidate(absl::WrapUnique(webrtc::CreateIceCandidate(
+                              sdp_mid, sdp_mline_index, msg, nullptr)),
+                          [&result](RTCError r) { result = r; });
+    EXPECT_TRUE_WAIT(result.has_value(), kDefaultTimeout);
+    EXPECT_TRUE(result.value().ok());
   }
 
   // PeerConnectionObserver callbacks.