From a06ebab1e19e7887d627a0da6e123d8b08fa59b6 Mon Sep 17 00:00:00 2001 From: "fischman@webrtc.org" Date: Mon, 3 Feb 2014 19:11:29 +0000 Subject: [PATCH] PeerConnectionTest(java): test SCTP DataChannels. BUG=1408,2253,2626 R=jiayl@webrtc.org Review URL: https://webrtc-codereview.appspot.com/7929004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5477 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../java/src/org/webrtc/DataChannel.java | 2 +- .../src/org/webrtc/PeerConnectionTest.java | 44 ++++++++----------- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/talk/app/webrtc/java/src/org/webrtc/DataChannel.java b/talk/app/webrtc/java/src/org/webrtc/DataChannel.java index d20e42d98..d59c47a91 100644 --- a/talk/app/webrtc/java/src/org/webrtc/DataChannel.java +++ b/talk/app/webrtc/java/src/org/webrtc/DataChannel.java @@ -39,7 +39,7 @@ public class DataChannel { // Optional unsigned short in WebIDL, -1 means unspecified. public int maxRetransmits = -1; public String protocol = ""; - public boolean negotiated = true; + public boolean negotiated = false; // Optional unsigned short in WebIDL, -1 means unspecified. public int id = -1; diff --git a/talk/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java b/talk/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java index e81f75a0d..bb59b7dc9 100644 --- a/talk/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java +++ b/talk/app/webrtc/javatests/src/org/webrtc/PeerConnectionTest.java @@ -509,12 +509,6 @@ public class PeerConnectionTest extends TestCase { MediaConstraints pcConstraints = new MediaConstraints(); pcConstraints.mandatory.add( new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true")); - pcConstraints.optional.add( - new MediaConstraints.KeyValuePair("RtpDataChannels", "true")); - // TODO(fischman): replace above with below to test SCTP channels when - // supported (https://code.google.com/p/webrtc/issues/detail?id=1408). - // pcConstraints.optional.add(new MediaConstraints.KeyValuePair( - // "internalSctpDataChannels", "true")); LinkedList iceServers = new LinkedList(); @@ -567,7 +561,9 @@ public class PeerConnectionTest extends TestCase { answeringExpectations.expectSignalingChange( SignalingState.HAVE_REMOTE_OFFER); answeringExpectations.expectAddStream("oLMS"); - answeringExpectations.expectDataChannel("offeringDC"); + // SCTP DataChannels are announced via OPEN messages over the established + // connection (not via SDP), so answeringExpectations can only register + // expecting the channel during ICE, below. answeringPC.setRemoteDescription(sdpLatch, offerSdp); assertEquals( PeerConnection.SignalingState.STABLE, offeringPC.signalingState()); @@ -638,6 +634,8 @@ public class PeerConnectionTest extends TestCase { IceConnectionState.CONNECTED); offeringExpectations.expectStateChange(DataChannel.State.OPEN); + // See commentary about SCTP DataChannels above for why this is here. + answeringExpectations.expectDataChannel("offeringDC"); answeringExpectations.expectStateChange(DataChannel.State.OPEN); for (IceCandidate candidate : offeringExpectations.gotIceCandidates) { @@ -665,29 +663,25 @@ public class PeerConnectionTest extends TestCase { assertTrue(offeringExpectations.dataChannel.send(buffer)); answeringExpectations.waitForAllExpectationsToBeSatisfied(); - // TODO(fischman): add testing of binary messages when SCTP channels are - // supported (https://code.google.com/p/webrtc/issues/detail?id=1408). - // // Construct this binary message two different ways to ensure no - // // shortcuts are taken. - // ByteBuffer expectedBinaryMessage = ByteBuffer.allocateDirect(5); - // for (byte i = 1; i < 6; ++i) { - // expectedBinaryMessage.put(i); - // } - // expectedBinaryMessage.flip(); - // offeringExpectations.expectMessage(expectedBinaryMessage, true); - // assertTrue(answeringExpectations.dataChannel.send( - // new DataChannel.Buffer( - // ByteBuffer.wrap(new byte[] { 1, 2, 3, 4, 5 } ), true))); - // offeringExpectations.waitForAllExpectationsToBeSatisfied(); + // Construct this binary message two different ways to ensure no + // shortcuts are taken. + ByteBuffer expectedBinaryMessage = ByteBuffer.allocateDirect(5); + for (byte i = 1; i < 6; ++i) { + expectedBinaryMessage.put(i); + } + expectedBinaryMessage.flip(); + offeringExpectations.expectMessage(expectedBinaryMessage, true); + assertTrue(answeringExpectations.dataChannel.send( + new DataChannel.Buffer( + ByteBuffer.wrap(new byte[] { 1, 2, 3, 4, 5 } ), true))); + offeringExpectations.waitForAllExpectationsToBeSatisfied(); offeringExpectations.expectStateChange(DataChannel.State.CLOSING); answeringExpectations.expectStateChange(DataChannel.State.CLOSING); + offeringExpectations.expectStateChange(DataChannel.State.CLOSED); + answeringExpectations.expectStateChange(DataChannel.State.CLOSED); answeringExpectations.dataChannel.close(); offeringExpectations.dataChannel.close(); - // TODO(fischman): implement a new offer/answer exchange to finalize the - // closing of the channel in order to see the CLOSED state reached. - // offeringExpectations.expectStateChange(DataChannel.State.CLOSED); - // answeringExpectations.expectStateChange(DataChannel.State.CLOSED); if (RENDER_TO_GUI) { try {