Change connection ASSERT into metrics for the PC level framework.

Bug: webrtc:11504
Change-Id: I48b2f44a52b18fd4bb3e75e9ccdcd842ec1faaed
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174022
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Andrey Logvin <landrey@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31142}
diff --git a/test/pc/e2e/BUILD.gn b/test/pc/e2e/BUILD.gn
index 5c1ee9d..73a73af 100644
--- a/test/pc/e2e/BUILD.gn
+++ b/test/pc/e2e/BUILD.gn
@@ -351,6 +351,7 @@
       ":video_quality_metrics_reporter",
       "../..:field_trial",
       "../..:fileutils",
+      "../..:perf_test",
       "../../../api:audio_quality_analyzer_api",
       "../../../api:libjingle_peerconnection_api",
       "../../../api:media_stream_interface",
diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc
index c5c9388..7802468 100644
--- a/test/pc/e2e/peer_connection_quality_test.cc
+++ b/test/pc/e2e/peer_connection_quality_test.cc
@@ -35,6 +35,7 @@
 #include "test/pc/e2e/stats_poller.h"
 #include "test/pc/e2e/test_peer_factory.h"
 #include "test/testsupport/file_utils.h"
+#include "test/testsupport/perf_test.h"
 
 namespace webrtc {
 namespace webrtc_pc_e2e {
@@ -342,6 +343,7 @@
     real_test_duration_ = end_time - start_time;
   }
 
+  ReportGeneralTestResults();
   audio_quality_analyzer_->Stop();
   video_quality_analyzer_injection_helper_->Stop();
   for (auto& reporter : quality_metrics_reporters_) {
@@ -537,9 +539,10 @@
 
   ExchangeIceCandidates(&signaling_interceptor);
   // This means that ICE and DTLS are connected.
-  ASSERT_TRUE_WAIT(bob_->IsIceConnected(), kDefaultTimeoutMs);
-  ASSERT_TRUE_WAIT(alice_->IsIceConnected(), kDefaultTimeoutMs);
-  RTC_LOG(INFO) << "Call is started (all peers are connected).";
+  WAIT(bob_->IsIceConnected(), kDefaultTimeoutMs);
+  bob_connected_ = bob_->IsIceConnected();
+  WAIT(alice_->IsIceConnected(), kDefaultTimeoutMs);
+  alice_connected_ = alice_->IsIceConnected();
 }
 
 void PeerConnectionE2EQualityTest::ExchangeOfferAnswer(
@@ -635,6 +638,15 @@
   media_helper_.reset();
 }
 
+void PeerConnectionE2EQualityTest::ReportGeneralTestResults() {
+  test::PrintResult(
+      "alice_connected", "", test_case_name_, alice_connected_, "unitless",
+      /*important=*/false, test::ImproveDirection::kBiggerIsBetter);
+  test::PrintResult(
+      "bob_connected", "", test_case_name_, bob_connected_, "unitless",
+      /*important=*/false, test::ImproveDirection::kBiggerIsBetter);
+}
+
 Timestamp PeerConnectionE2EQualityTest::Now() const {
   return clock_->CurrentTime();
 }
diff --git a/test/pc/e2e/peer_connection_quality_test.h b/test/pc/e2e/peer_connection_quality_test.h
index 081235b..bbc3d8a 100644
--- a/test/pc/e2e/peer_connection_quality_test.h
+++ b/test/pc/e2e/peer_connection_quality_test.h
@@ -95,6 +95,7 @@
       const std::vector<rtc::scoped_refptr<TestVideoCapturerVideoTrackSource>>&
           sources);
   void TearDownCall();
+  void ReportGeneralTestResults();
   Timestamp Now() const;
 
   Clock* const clock_;
@@ -132,6 +133,9 @@
   // This task queue will be created before call set up and will be destroyed
   // immediately before call tear down.
   std::unique_ptr<TaskQueueForTest> task_queue_;
+
+  bool alice_connected_ = false;
+  bool bob_connected_ = false;
 };
 
 }  // namespace webrtc_pc_e2e