From 5f0d0e737e3e20d261eadb50f92be0faf55fbcfd Mon Sep 17 00:00:00 2001 From: Rasmus Brandt Date: Fri, 4 May 2018 11:33:34 +0200 Subject: [PATCH] Re-enable PeerConnectionTest#testTrackRemovalAndAddition. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let the test expect calls to onRenegotiationNeeded(), as introduced by https://codereview.webrtc.org/2977493002. Bug: webrtc:7761 Change-Id: If8e3c484236f6599cc225a0398bbbc9cf6c356a5 Reviewed-on: https://webrtc-review.googlesource.com/48364 Reviewed-by: Sami Kalliomäki Reviewed-by: Taylor Brandstetter Commit-Queue: Rasmus Brandt Cr-Commit-Position: refs/heads/master@{#23165} --- .../src/org/webrtc/PeerConnectionTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java index 08d9ea0716..9aeda834a0 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java @@ -250,8 +250,9 @@ public class PeerConnectionTest { WeakReference videoSink = videoSinks.remove(stream); assertNotNull(videoSink); assertNotNull(videoSink.get()); - assertEquals(1, stream.videoTracks.size()); - stream.videoTracks.get(0).removeSink(videoSink.get()); + for (VideoTrack videoTrack : stream.videoTracks) { + videoTrack.removeSink(videoSink.get()); + } gotRemoteStreams.remove(stream); } @@ -1054,8 +1055,6 @@ public class PeerConnectionTest { System.gc(); } - // Flaky on Android. See webrtc:7761 - @DisabledTest @Test @MediumTest public void testTrackRemovalAndAddition() throws Exception { @@ -1194,19 +1193,17 @@ public class PeerConnectionTest { VideoTrack offererVideoTrack = oLMS.get().videoTracks.get(0); // Note that when we call removeTrack, we regain responsibility for // disposing of the track. + offeringExpectations.expectRenegotiationNeeded(); oLMS.get().removeTrack(offererVideoTrack); negotiate(offeringPC, offeringExpectations, answeringPC, answeringExpectations); // Make sure the track was really removed. - // TODO(deadbeef): Currently the expectation is that the video track's - // state will be set to "ended". However, in the future, it's likely that - // the video track will be completely removed from the remote stream - // (as it is on the C++ level). MediaStream aRMS = answeringExpectations.gotRemoteStreams.iterator().next(); - assertEquals(aRMS.videoTracks.get(0).state(), MediaStreamTrack.State.ENDED); + assertTrue(aRMS.videoTracks.isEmpty()); // Add the video track to test if the answeringPC will create a new track // for the updated remote description. + offeringExpectations.expectRenegotiationNeeded(); oLMS.get().addTrack(offererVideoTrack); // The answeringPC sets the updated remote description with a track added. // So the onAddTrack callback is expected to be called once. @@ -1217,8 +1214,10 @@ public class PeerConnectionTest { // Finally, remove both the audio and video tracks, which should completely // remove the remote stream. This used to trigger an assert. // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=5128 + offeringExpectations.expectRenegotiationNeeded(); oLMS.get().removeTrack(offererVideoTrack); AudioTrack offererAudioTrack = oLMS.get().audioTracks.get(0); + offeringExpectations.expectRenegotiationNeeded(); oLMS.get().removeTrack(offererAudioTrack); answeringExpectations.expectRemoveStream("offeredMediaStream");