Add android bindings for PeerConnectionState.
This change makes it possible for android apps to use the new standards-compliant PeerConnectionState. Bug: webrtc:9977 Change-Id: Iad19c38e664a59e86879715ec7a04a59a9894bee Reviewed-on: https://webrtc-review.googlesource.com/c/109883 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25652}
This commit is contained in:
@ -45,6 +45,7 @@ import org.junit.runner.RunWith;
|
||||
import org.webrtc.Metrics.HistogramInfo;
|
||||
import org.webrtc.PeerConnection.IceConnectionState;
|
||||
import org.webrtc.PeerConnection.IceGatheringState;
|
||||
import org.webrtc.PeerConnection.PeerConnectionState;
|
||||
import org.webrtc.PeerConnection.SignalingState;
|
||||
|
||||
/** End-to-end tests for PeerConnection.java. */
|
||||
@ -74,6 +75,7 @@ public class PeerConnectionTest {
|
||||
private int expectedTracksAdded;
|
||||
private Queue<SignalingState> expectedSignalingChanges = new ArrayDeque<>();
|
||||
private Queue<IceConnectionState> expectedIceConnectionChanges = new ArrayDeque<>();
|
||||
private Queue<PeerConnectionState> expectedConnectionChanges = new ArrayDeque<>();
|
||||
private Queue<IceGatheringState> expectedIceGatheringChanges = new ArrayDeque<>();
|
||||
private Queue<String> expectedAddStreamLabels = new ArrayDeque<>();
|
||||
private Queue<String> expectedRemoveStreamLabels = new ArrayDeque<>();
|
||||
@ -188,11 +190,29 @@ public class PeerConnectionTest {
|
||||
assertEquals(expectedIceConnectionChanges.remove(), newState);
|
||||
}
|
||||
|
||||
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
|
||||
@SuppressWarnings("NoSynchronizedMethodCheck")
|
||||
public synchronized void expectConnectionChange(PeerConnectionState newState) {
|
||||
expectedConnectionChanges.add(newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
|
||||
@SuppressWarnings("NoSynchronizedMethodCheck")
|
||||
public synchronized void onConnectionChange(PeerConnectionState newState) {
|
||||
if (expectedConnectionChanges.isEmpty()) {
|
||||
System.out.println(name + " got an unexpected DTLS connection change " + newState);
|
||||
return;
|
||||
}
|
||||
|
||||
assertEquals(expectedConnectionChanges.remove(), newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
|
||||
@SuppressWarnings("NoSynchronizedMethodCheck")
|
||||
public synchronized void onIceConnectionReceivingChange(boolean receiving) {
|
||||
System.out.println(name + "Got an ICE connection receiving change " + receiving);
|
||||
System.out.println(name + " got an ICE connection receiving change " + receiving);
|
||||
}
|
||||
|
||||
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
|
||||
@ -799,12 +819,14 @@ public class PeerConnectionTest {
|
||||
|
||||
sdpLatch = new SdpObserverLatch();
|
||||
answeringExpectations.expectSignalingChange(SignalingState.STABLE);
|
||||
answeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
answeringPC.setLocalDescription(sdpLatch, answerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
assertNull(sdpLatch.getSdp());
|
||||
|
||||
sdpLatch = new SdpObserverLatch();
|
||||
offeringExpectations.expectSignalingChange(SignalingState.HAVE_LOCAL_OFFER);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
offeringPC.setLocalDescription(sdpLatch, offerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
assertNull(sdpLatch.getSdp());
|
||||
@ -814,6 +836,9 @@ public class PeerConnectionTest {
|
||||
|
||||
offeringExpectations.expectIceConnectionChange(IceConnectionState.CHECKING);
|
||||
offeringExpectations.expectIceConnectionChange(IceConnectionState.CONNECTED);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.NEW);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTED);
|
||||
// TODO(bemasc): uncomment once delivery of ICECompleted is reliable
|
||||
// (https://code.google.com/p/webrtc/issues/detail?id=3021).
|
||||
//
|
||||
@ -821,6 +846,7 @@ public class PeerConnectionTest {
|
||||
// IceConnectionState.COMPLETED);
|
||||
answeringExpectations.expectIceConnectionChange(IceConnectionState.CHECKING);
|
||||
answeringExpectations.expectIceConnectionChange(IceConnectionState.CONNECTED);
|
||||
answeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTED);
|
||||
|
||||
offeringPC.setRemoteDescription(sdpLatch, answerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
@ -1029,12 +1055,14 @@ public class PeerConnectionTest {
|
||||
|
||||
sdpLatch = new SdpObserverLatch();
|
||||
answeringExpectations.expectSignalingChange(SignalingState.STABLE);
|
||||
answeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
answeringPC.setLocalDescription(sdpLatch, answerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
assertNull(sdpLatch.getSdp());
|
||||
|
||||
sdpLatch = new SdpObserverLatch();
|
||||
offeringExpectations.expectSignalingChange(SignalingState.HAVE_LOCAL_OFFER);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
offeringPC.setLocalDescription(sdpLatch, offerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
assertNull(sdpLatch.getSdp());
|
||||
@ -1043,10 +1071,14 @@ public class PeerConnectionTest {
|
||||
|
||||
offeringExpectations.expectIceConnectionChange(IceConnectionState.CHECKING);
|
||||
offeringExpectations.expectIceConnectionChange(IceConnectionState.CONNECTED);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.NEW);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTED);
|
||||
// TODO(bemasc): uncomment once delivery of ICECompleted is reliable
|
||||
// (https://code.google.com/p/webrtc/issues/detail?id=3021).
|
||||
answeringExpectations.expectIceConnectionChange(IceConnectionState.CHECKING);
|
||||
answeringExpectations.expectIceConnectionChange(IceConnectionState.CONNECTED);
|
||||
answeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTED);
|
||||
|
||||
offeringPC.setRemoteDescription(sdpLatch, answerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
@ -1179,6 +1211,7 @@ public class PeerConnectionTest {
|
||||
offeringExpectations.expectSignalingChange(SignalingState.HAVE_LOCAL_OFFER);
|
||||
offeringExpectations.expectIceCandidates(2);
|
||||
offeringExpectations.expectIceGatheringChange(IceGatheringState.COMPLETE);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
offeringPC.setLocalDescription(sdpLatch, offerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
assertNull(sdpLatch.getSdp());
|
||||
@ -1210,6 +1243,7 @@ public class PeerConnectionTest {
|
||||
answeringExpectations.expectSignalingChange(SignalingState.STABLE);
|
||||
answeringExpectations.expectIceCandidates(2);
|
||||
answeringExpectations.expectIceGatheringChange(IceGatheringState.COMPLETE);
|
||||
answeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
answeringPC.setLocalDescription(sdpLatch, answerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
assertNull(sdpLatch.getSdp());
|
||||
@ -1221,6 +1255,9 @@ public class PeerConnectionTest {
|
||||
|
||||
offeringExpectations.expectIceConnectionChange(IceConnectionState.CHECKING);
|
||||
offeringExpectations.expectIceConnectionChange(IceConnectionState.CONNECTED);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.NEW);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTING);
|
||||
offeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTED);
|
||||
// TODO(bemasc): uncomment once delivery of ICECompleted is reliable
|
||||
// (https://code.google.com/p/webrtc/issues/detail?id=3021).
|
||||
//
|
||||
@ -1228,6 +1265,7 @@ public class PeerConnectionTest {
|
||||
// IceConnectionState.COMPLETED);
|
||||
answeringExpectations.expectIceConnectionChange(IceConnectionState.CHECKING);
|
||||
answeringExpectations.expectIceConnectionChange(IceConnectionState.CONNECTED);
|
||||
answeringExpectations.expectConnectionChange(PeerConnectionState.CONNECTED);
|
||||
|
||||
offeringPC.setRemoteDescription(sdpLatch, answerSdp);
|
||||
assertTrue(sdpLatch.await());
|
||||
@ -1613,6 +1651,7 @@ public class PeerConnectionTest {
|
||||
assertTrue(expectations.waitForAllExpectationsToBeSatisfied(TIMEOUT_SECONDS));
|
||||
|
||||
expectations.expectIceConnectionChange(IceConnectionState.CLOSED);
|
||||
expectations.expectConnectionChange(PeerConnectionState.CLOSED);
|
||||
expectations.expectSignalingChange(SignalingState.CLOSED);
|
||||
pc.close();
|
||||
assertTrue(expectations.waitForAllExpectationsToBeSatisfied(TIMEOUT_SECONDS));
|
||||
|
||||
Reference in New Issue
Block a user