Add a PeerConnection integration test for adding an audio track mid-call

BUG=None

Review-Url: https://codereview.webrtc.org/3007923002
Cr-Original-Commit-Position: refs/heads/master@{#19731}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 4389b4d96bb98cf210b761b4f152434fceb767a6
diff --git a/pc/peerconnection_integrationtest.cc b/pc/peerconnection_integrationtest.cc
index d20e2f9..6b3ddd5 100644
--- a/pc/peerconnection_integrationtest.cc
+++ b/pc/peerconnection_integrationtest.cc
@@ -1393,8 +1393,7 @@
   // Initially, offer an audio/video stream from the caller, but refuse to
   // send/receive video on the callee side.
   caller()->AddAudioVideoMediaStream();
-  callee()->AddMediaStreamFromTracks(callee()->CreateLocalAudioTrack(),
-                                     nullptr);
+  callee()->AddAudioOnlyMediaStream();
   PeerConnectionInterface::RTCOfferAnswerOptions options;
   options.offer_to_receive_video = 0;
   callee()->SetOfferAnswerOptions(options);
@@ -1425,6 +1424,30 @@
       kMaxWaitForFramesMs);
 }
 
+// Simpler than the above test; just add an audio track to an established
+// video-only connection.
+TEST_F(PeerConnectionIntegrationTest, AddAudioToVideoOnlyCall) {
+  ASSERT_TRUE(CreatePeerConnectionWrappers());
+  ConnectFakeSignaling();
+  // Do initial offer/answer with just a video track.
+  caller()->AddVideoOnlyMediaStream();
+  callee()->AddVideoOnlyMediaStream();
+  caller()->CreateAndSetAndSignalOffer();
+  ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+  // Now add an audio track and do another offer/answer.
+  caller()->AddMediaStreamFromTracksWithLabel(caller()->CreateLocalAudioTrack(),
+                                              nullptr, "audio_stream");
+  callee()->AddMediaStreamFromTracksWithLabel(callee()->CreateLocalAudioTrack(),
+                                              nullptr, "audio_stream");
+  caller()->CreateAndSetAndSignalOffer();
+  ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+  // Ensure both audio and video frames are received end-to-end.
+  ExpectNewFramesReceivedWithWait(
+      kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
+      kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
+      kMaxWaitForFramesMs);
+}
+
 // This test sets up a call that's transferred to a new caller with a different
 // DTLS fingerprint.
 TEST_F(PeerConnectionIntegrationTest, CallTransferredForCallee) {