Replace use of ASSERT in test code.

In top level test functions, replaced with gtest ASSERT_*. In helper
methods in main test files, replaced with EXPECT_* or RTC_DCHECK on a
case-by-case basis.

In separate mock/fake classes used by tests (which might be of some
use also in tests of third-party applications), ASSERT was replaced
with RTC_CHECK, using

  git grep -l ' ASSERT(' | grep -v common.h | \
    xargs sed -i 's/ ASSERT(/ RTC_CHECK(/'

followed by additional includes of base/checks.h in affected files,
and git cl format.

BUG=webrtc:6424

Review-Url: https://codereview.webrtc.org/2622413005
Cr-Commit-Position: refs/heads/master@{#16150}
diff --git a/webrtc/api/rtcstatscollector_unittest.cc b/webrtc/api/rtcstatscollector_unittest.cc
index f8efb24..0ba9abf 100644
--- a/webrtc/api/rtcstatscollector_unittest.cc
+++ b/webrtc/api/rtcstatscollector_unittest.cc
@@ -790,22 +790,22 @@
   expected_outbound_video_codec.codec = "video/VP8";
   expected_outbound_video_codec.clock_rate = 1340;
 
-  ASSERT(report->Get(expected_inbound_audio_codec.id()));
+  ASSERT_TRUE(report->Get(expected_inbound_audio_codec.id()));
   EXPECT_EQ(expected_inbound_audio_codec,
             report->Get(expected_inbound_audio_codec.id())->cast_to<
                   RTCCodecStats>());
 
-  ASSERT(report->Get(expected_outbound_audio_codec.id()));
+  ASSERT_TRUE(report->Get(expected_outbound_audio_codec.id()));
   EXPECT_EQ(expected_outbound_audio_codec,
             report->Get(expected_outbound_audio_codec.id())->cast_to<
                   RTCCodecStats>());
 
-  ASSERT(report->Get(expected_inbound_video_codec.id()));
+  ASSERT_TRUE(report->Get(expected_inbound_video_codec.id()));
   EXPECT_EQ(expected_inbound_video_codec,
             report->Get(expected_inbound_video_codec.id())->cast_to<
                   RTCCodecStats>());
 
-  ASSERT(report->Get(expected_outbound_video_codec.id()));
+  ASSERT_TRUE(report->Get(expected_outbound_video_codec.id()));
   EXPECT_EQ(expected_outbound_video_codec,
             report->Get(expected_outbound_video_codec.id())->cast_to<
                   RTCCodecStats>());
@@ -1618,7 +1618,7 @@
   expected_audio.jitter = 4.5;
   expected_audio.fraction_lost = 5.5;
 
-  ASSERT(report->Get(expected_audio.id()));
+  ASSERT_TRUE(report->Get(expected_audio.id()));
   const RTCInboundRTPStreamStats& audio = report->Get(
       expected_audio.id())->cast_to<RTCInboundRTPStreamStats>();
   EXPECT_EQ(audio, expected_audio);
@@ -1703,7 +1703,7 @@
   expected_video.fraction_lost = 4.5;
   expected_video.frames_decoded = 8;
 
-  ASSERT(report->Get(expected_video.id()));
+  ASSERT_TRUE(report->Get(expected_video.id()));
   const RTCInboundRTPStreamStats& video = report->Get(
       expected_video.id())->cast_to<RTCInboundRTPStreamStats>();
   EXPECT_EQ(video, expected_video);
@@ -1776,7 +1776,7 @@
   expected_audio.bytes_sent = 3;
   expected_audio.round_trip_time = 4.5;
 
-  ASSERT(report->Get(expected_audio.id()));
+  ASSERT_TRUE(report->Get(expected_audio.id()));
   const RTCOutboundRTPStreamStats& audio = report->Get(
       expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>();
   EXPECT_EQ(audio, expected_audio);
@@ -1859,7 +1859,7 @@
   expected_video.frames_encoded = 8;
   expected_video.qp_sum = 16;
 
-  ASSERT(report->Get(expected_video.id()));
+  ASSERT_TRUE(report->Get(expected_video.id()));
   const RTCOutboundRTPStreamStats& video = report->Get(
       expected_video.id())->cast_to<RTCOutboundRTPStreamStats>();
   EXPECT_EQ(video, expected_video);
@@ -1943,7 +1943,7 @@
   expected_audio.bytes_sent = 3;
   // |expected_audio.round_trip_time| should be undefined.
 
-  ASSERT(report->Get(expected_audio.id()));
+  ASSERT_TRUE(report->Get(expected_audio.id()));
   const RTCOutboundRTPStreamStats& audio = report->Get(
       expected_audio.id())->cast_to<RTCOutboundRTPStreamStats>();
   EXPECT_EQ(audio, expected_audio);
@@ -1965,7 +1965,7 @@
   // |expected_video.round_trip_time| should be undefined.
   // |expected_video.qp_sum| should be undefined.
 
-  ASSERT(report->Get(expected_video.id()));
+  ASSERT_TRUE(report->Get(expected_video.id()));
   const RTCOutboundRTPStreamStats& video = report->Get(
       expected_video.id())->cast_to<RTCOutboundRTPStreamStats>();
   EXPECT_EQ(video, expected_video);
diff --git a/webrtc/api/statscollector_unittest.cc b/webrtc/api/statscollector_unittest.cc
index 30bb2b8..f72e355 100644
--- a/webrtc/api/statscollector_unittest.cc
+++ b/webrtc/api/statscollector_unittest.cc
@@ -618,7 +618,7 @@
       StatsReports* reports) {
     // A track can't have both sender report and recv report at the same time
     // for now, this might change in the future though.
-    ASSERT((voice_sender_info == NULL) ^ (voice_receiver_info == NULL));
+    EXPECT_TRUE((voice_sender_info == NULL) ^ (voice_receiver_info == NULL));
 
     // Instruct the session to return stats containing the transport channel.
     InitSessionStats(vc_name);
@@ -1315,7 +1315,7 @@
   uint32_t priority = 1000;
 
   cricket::Candidate c;
-  ASSERT(c.id().length() > 0);
+  EXPECT_GT(c.id().length(), 0u);
   c.set_type(cricket::LOCAL_PORT_TYPE);
   c.set_protocol(cricket::UDP_PROTOCOL_NAME);
   c.set_address(local_address);
@@ -1325,7 +1325,7 @@
   EXPECT_EQ("Cand-" + c.id(), report_id);
 
   c = cricket::Candidate();
-  ASSERT(c.id().length() > 0);
+  EXPECT_GT(c.id().length(), 0u);
   c.set_type(cricket::PRFLX_PORT_TYPE);
   c.set_protocol(cricket::UDP_PROTOCOL_NAME);
   c.set_address(remote_address);
diff --git a/webrtc/api/test/fakeaudiocapturemodule.cc b/webrtc/api/test/fakeaudiocapturemodule.cc
index f118967..c0b761f 100644
--- a/webrtc/api/test/fakeaudiocapturemodule.cc
+++ b/webrtc/api/test/fakeaudiocapturemodule.cc
@@ -639,7 +639,7 @@
 }
 
 void FakeAudioCaptureModule::StartProcessP() {
-  ASSERT(process_thread_->IsCurrent());
+  RTC_CHECK(process_thread_->IsCurrent());
   if (started_) {
     // Already started.
     return;
@@ -648,7 +648,7 @@
 }
 
 void FakeAudioCaptureModule::ProcessFrameP() {
-  ASSERT(process_thread_->IsCurrent());
+  RTC_CHECK(process_thread_->IsCurrent());
   if (!started_) {
     next_frame_time_ = rtc::TimeMillis();
     started_ = true;
@@ -673,7 +673,7 @@
 }
 
 void FakeAudioCaptureModule::ReceiveFrameP() {
-  ASSERT(process_thread_->IsCurrent());
+  RTC_CHECK(process_thread_->IsCurrent());
   {
     rtc::CritScope cs(&crit_callback_);
     if (!audio_callback_) {
@@ -689,7 +689,7 @@
                                          &elapsed_time_ms, &ntp_time_ms) != 0) {
       RTC_NOTREACHED();
     }
-    ASSERT(nSamplesOut == kNumberSamples);
+    RTC_CHECK(nSamplesOut == kNumberSamples);
   }
   // The SetBuffer() function ensures that after decoding, the audio buffer
   // should contain samples of similar magnitude (there is likely to be some
@@ -704,7 +704,7 @@
 }
 
 void FakeAudioCaptureModule::SendFrameP() {
-  ASSERT(process_thread_->IsCurrent());
+  RTC_CHECK(process_thread_->IsCurrent());
   rtc::CritScope cs(&crit_callback_);
   if (!audio_callback_) {
     return;
diff --git a/webrtc/api/test/fakedatachannelprovider.h b/webrtc/api/test/fakedatachannelprovider.h
index 3404ac1..3e796a3 100644
--- a/webrtc/api/test/fakedatachannelprovider.h
+++ b/webrtc/api/test/fakedatachannelprovider.h
@@ -12,6 +12,7 @@
 #define WEBRTC_API_TEST_FAKEDATACHANNELPROVIDER_H_
 
 #include "webrtc/api/datachannel.h"
+#include "webrtc/base/checks.h"
 
 class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
  public:
@@ -25,7 +26,7 @@
   bool SendData(const cricket::SendDataParams& params,
                 const rtc::CopyOnWriteBuffer& payload,
                 cricket::SendDataResult* result) override {
-    ASSERT(ready_to_send_ && transport_available_);
+    RTC_CHECK(ready_to_send_ && transport_available_);
     if (send_blocked_) {
       *result = cricket::SDR_BLOCK;
       return false;
@@ -41,7 +42,8 @@
   }
 
   bool ConnectDataChannel(webrtc::DataChannel* data_channel) override {
-    ASSERT(connected_channels_.find(data_channel) == connected_channels_.end());
+    RTC_CHECK(connected_channels_.find(data_channel) ==
+              connected_channels_.end());
     if (!transport_available_) {
       return false;
     }
@@ -51,13 +53,14 @@
   }
 
   void DisconnectDataChannel(webrtc::DataChannel* data_channel) override {
-    ASSERT(connected_channels_.find(data_channel) != connected_channels_.end());
+    RTC_CHECK(connected_channels_.find(data_channel) !=
+              connected_channels_.end());
     LOG(LS_INFO) << "DataChannel disconnected " << data_channel;
     connected_channels_.erase(data_channel);
   }
 
   void AddSctpDataStream(int sid) override {
-    ASSERT(sid >= 0);
+    RTC_CHECK(sid >= 0);
     if (!transport_available_) {
       return;
     }
@@ -66,7 +69,7 @@
   }
 
   void RemoveSctpDataStream(int sid) override {
-    ASSERT(sid >= 0);
+    RTC_CHECK(sid >= 0);
     send_ssrcs_.erase(sid);
     recv_ssrcs_.erase(sid);
   }
@@ -99,7 +102,7 @@
   // Set true to emulate the transport ReadyToSendData signal when the transport
   // becomes writable for the first time.
   void set_ready_to_send(bool ready) {
-    ASSERT(transport_available_);
+    RTC_CHECK(transport_available_);
     ready_to_send_ = ready;
     if (ready) {
       std::set<webrtc::DataChannel*>::iterator it;
diff --git a/webrtc/api/test/mockpeerconnectionobservers.h b/webrtc/api/test/mockpeerconnectionobservers.h
index 23647f6..1f000af 100644
--- a/webrtc/api/test/mockpeerconnectionobservers.h
+++ b/webrtc/api/test/mockpeerconnectionobservers.h
@@ -17,6 +17,7 @@
 #include <string>
 
 #include "webrtc/api/datachannelinterface.h"
+#include "webrtc/base/checks.h"
 
 namespace webrtc {
 
@@ -109,7 +110,7 @@
   virtual ~MockStatsObserver() {}
 
   virtual void OnComplete(const StatsReports& reports) {
-    ASSERT(!called_);
+    RTC_CHECK(!called_);
     called_ = true;
     stats_.Clear();
     stats_.number_of_reports = reports.size();
@@ -143,37 +144,37 @@
   double timestamp() const { return stats_.timestamp; }
 
   int AudioOutputLevel() const {
-    ASSERT(called_);
+    RTC_CHECK(called_);
     return stats_.audio_output_level;
   }
 
   int AudioInputLevel() const {
-    ASSERT(called_);
+    RTC_CHECK(called_);
     return stats_.audio_input_level;
   }
 
   int BytesReceived() const {
-    ASSERT(called_);
+    RTC_CHECK(called_);
     return stats_.bytes_received;
   }
 
   int BytesSent() const {
-    ASSERT(called_);
+    RTC_CHECK(called_);
     return stats_.bytes_sent;
   }
 
   int AvailableReceiveBandwidth() const {
-    ASSERT(called_);
+    RTC_CHECK(called_);
     return stats_.available_receive_bandwidth;
   }
 
   std::string DtlsCipher() const {
-    ASSERT(called_);
+    RTC_CHECK(called_);
     return stats_.dtls_cipher;
   }
 
   std::string SrtpCipher() const {
-    ASSERT(called_);
+    RTC_CHECK(called_);
     return stats_.srtp_cipher;
   }
 
diff --git a/webrtc/api/webrtcsession_unittest.cc b/webrtc/api/webrtcsession_unittest.cc
index 3e1a583..ca09315 100644
--- a/webrtc/api/webrtcsession_unittest.cc
+++ b/webrtc/api/webrtcsession_unittest.cc
@@ -1450,10 +1450,10 @@
 
   bool VerifyNoCNCodecs(const cricket::ContentInfo* content) {
     const cricket::ContentDescription* description = content->description;
-    ASSERT(description != NULL);
+    RTC_CHECK(description != NULL);
     const cricket::AudioContentDescription* audio_content_desc =
         static_cast<const cricket::AudioContentDescription*>(description);
-    ASSERT(audio_content_desc != NULL);
+    RTC_CHECK(audio_content_desc != NULL);
     for (size_t i = 0; i < audio_content_desc->codecs().size(); ++i) {
       if (audio_content_desc->codecs()[i].name == "CN")
         return false;
@@ -1463,7 +1463,7 @@
 
   void CreateDataChannel() {
     webrtc::InternalDataChannelInit dci;
-    ASSERT(session_.get());
+    RTC_CHECK(session_.get());
     dci.reliable = session_->data_channel_type() == cricket::DCT_SCTP;
     data_channel_ = DataChannel::Create(
         session_.get(), session_->data_channel_type(), "datachannel", dci);
@@ -3082,7 +3082,7 @@
             session_->video_rtp_transport_channel());
 
   cricket::BaseChannel* voice_channel = session_->voice_channel();
-  ASSERT(voice_channel != NULL);
+  ASSERT_TRUE(voice_channel != NULL);
 
   // Checks if one of the transport channels contains a connection using a given
   // port.