Remove gunit's WAIT_ macro

WaitUntil returns the value so this macro is not needed.

Bug: webrtc:381524905
Change-Id: Iefc560916c0caa192dbec489f5200352eeb62c0d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/407445
Auto-Submit: Evan Shrubsole <eshr@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45537}
diff --git a/pc/slow_peer_connection_integration_test.cc b/pc/slow_peer_connection_integration_test.cc
index 42d91ab..ffbff22 100644
--- a/pc/slow_peer_connection_integration_test.cc
+++ b/pc/slow_peer_connection_integration_test.cc
@@ -35,7 +35,6 @@
 #include "rtc_base/fake_clock.h"
 #include "rtc_base/fake_network.h"
 #include "rtc_base/firewall_socket_server.h"
-#include "rtc_base/gunit.h"
 #include "rtc_base/logging.h"
 #include "rtc_base/socket_address.h"
 #include "rtc_base/test_certificate_verifier.h"
@@ -222,11 +221,11 @@
   options.offer_to_receive_video = 1;
   caller()->SetOfferAnswerOptions(options);
   caller()->CreateAndSetAndSignalOffer();
-  bool wait_res = true;
+  bool wait_res = WaitUntil([&]() { return DtlsConnected(); },
+                            {.timeout = kDefaultTimeout});
   // TODO(bugs.webrtc.org/9219): When IceConnectionState is implemented
   // properly, should be able to just wait for a state of "failed" instead of
   // waiting a fixed 10 seconds.
-  WAIT_(DtlsConnected(), kDefaultTimeout.ms(), wait_res);
   ASSERT_FALSE(wait_res);
 
   EXPECT_GT(client_1_cert_verifier->call_count_, 0u);
@@ -255,15 +254,14 @@
 
   // Get the audio output level stats. Note that the level is not available
   // until an RTCP packet has been received.
-  EXPECT_THAT(
-      WaitUntil(
-          [&] {
-            return callee()
-                ->OldGetStatsForTrack(remote_audio_track.get())
-                ->CaptureStartNtpTime();
-          },
-          ::testing::Gt(0), {.timeout = 2 * kMaxWaitForFrames}),
-      IsRtcOk());
+  EXPECT_THAT(WaitUntil(
+                  [&] {
+                    return callee()
+                        ->OldGetStatsForTrack(remote_audio_track.get())
+                        ->CaptureStartNtpTime();
+                  },
+                  ::testing::Gt(0), {.timeout = 2 * kMaxWaitForFrames}),
+              IsRtcOk());
 }
 
 // Test that firewalling the ICE connection causes the clients to identify the
diff --git a/rtc_base/gunit.h b/rtc_base/gunit.h
index 014f353..cdb2fd4 100644
--- a/rtc_base/gunit.h
+++ b/rtc_base/gunit.h
@@ -23,20 +23,6 @@
     ::webrtc::Thread::Current()->SleepMs(1);                              \
   }
 
-// This returns the result of the test in res, so that we don't re-evaluate
-// the expression in the XXXX_WAIT macros below, since that causes problems
-// when the expression is only true the first time you check it.
-#define WAIT_(ex, timeout, res)                                             \
-  do {                                                                      \
-    int64_t wait_start = ::webrtc::SystemTimeMillis();                      \
-    res = (ex) && true;                                                     \
-    while (!res && ::webrtc::SystemTimeMillis() < wait_start + (timeout)) { \
-      ::webrtc::Thread::Current()->ProcessMessages(0);                      \
-      ::webrtc::Thread::Current()->SleepMs(1);                              \
-      res = (ex) && true;                                                   \
-    }                                                                       \
-  } while (0)
-
 // Wait until "ex" is true, or "timeout" expires, using fake clock where
 // messages are processed every millisecond.
 // TODO(pthatcher): Allow tests to control how many milliseconds to advance.