Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Unified Diff: content/test/data/media/peerconnection-setAndGetConfiguration.html

Issue 2706563003: Create the API that returns the RTCConfiguration of the PeerConnection.
Patch Set: rebaselining Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/test/data/media/peerconnection-setAndGetConfiguration.html
diff --git a/content/test/data/media/peerconnection-setConfiguration.html b/content/test/data/media/peerconnection-setAndGetConfiguration.html
similarity index 62%
rename from content/test/data/media/peerconnection-setConfiguration.html
rename to content/test/data/media/peerconnection-setAndGetConfiguration.html
index 8a896c15db4863d6b0d5800d8fcbe47ddc49ddac..e659f297c5a759e8b93772990f56d8f0762ea826 100644
--- a/content/test/data/media/peerconnection-setConfiguration.html
+++ b/content/test/data/media/peerconnection-setAndGetConfiguration.html
@@ -15,36 +15,46 @@
var gPeerConnection = null;
var gCertificate = null;
+ var retrievedCertificate = null;
+ var gRtcConfig = null;
// This test creates and sets three offers, calling setConfiguration in
// between each offer, expecting an ICE restart to be triggered by the next
// offer.
- function testSetConfiguration() {
- gPeerConnection = new RTCPeerConnection(
- {iceServers:[], iceTransportPolicy:'all', bundlePolicy:'balanced',
- rtcpMuxPolicy:'require', certificates:[], iceCandidatePoolSize:0});
- // Change ICE candidate pool size, which will succeed before
- // setLocalDescription is called.
- gPeerConnection.setConfiguration(
- {iceServers:[], iceTransportPolicy:'all', bundlePolicy:'balanced',
- rtcpMuxPolicy:'require', certificates:[], iceCandidatePoolSize:1});
- // Now test successful cases of setConfiguration. Changes should trigger an
- // ICE restart in the next offer. To do this, first we need to trigger an
- // initial ICE gathering phase and wait until it completes.
- // TODO(deadbeef): Once onicegatheringstatechange is implemented, use that
- // instead of a "null" candidate.
- gPeerConnection.onicecandidate = iceCandidateCallback1;
- createOfferAndSetLocalDescription();
+ function testSetAndGetConfiguration() {
foolip 2017/03/21 08:37:14 It looks like much of this could be tested in web-
+ RTCPeerConnection.generateCertificate({ name:'ECDSA', namedCurve:'P-256' })
+ .then(function(cert) {
+ gRtcConfig =
+ {iceServers:[], iceTransportPolicy:'all', bundlePolicy:'balanced',
+ rtcpMuxPolicy:'require', certificates:[cert]};
+ gPeerConnection = new RTCPeerConnection(gRtcConfig);
+ // Now test successful cases of setConfiguration. Changes should trigger an
+ // ICE restart in the next offer. To do this, first we need to trigger an
+ // initial ICE gathering phase and wait until it completes.
+ // TODO(deadbeef): Once onicegatheringstatechange is implemented, use that
+ // instead of a "null" candidate.
+ gPeerConnection.onicecandidate = iceCandidateCallback1;
+ createOfferAndSetLocalDescription();
+ var retrievedRtcConfig = gPeerConnection.getConfiguration();
+ assertRtcConfigEquals(gRtcConfig, retrievedRtcConfig);
+ // Tests that the certificates can be successfully retrieved using
+ // getConfiguration() by re-applying the retrieved certification to the
+ // peerconnection.
+ assertEquals(1, retrievedRtcConfig['certificates'].length)
+ retrievedCertificate = gPeerConnection.getConfiguration()['certificates'][0];
+ });
}
function iceCandidateCallback1(candidate) {
if (gPeerConnection.iceGatheringState === 'complete') {
gPeerConnection.onicecandidate = iceCandidateCallback2;
// Policy changed.
- gPeerConnection.setConfiguration(
+ gRtcConfig =
{iceServers:[], iceTransportPolicy:'relay', bundlePolicy:'balanced',
- rtcpMuxPolicy:'require', certificates:[], iceCandidatePoolSize:1});
+ rtcpMuxPolicy:'require', certificates:[retrievedCertificate]};
+ gPeerConnection.setConfiguration(gRtcConfig);
createOfferAndSetLocalDescription();
+ assertRtcConfigEquals(gRtcConfig, gPeerConnection.getConfiguration());
}
}
@@ -52,11 +62,31 @@
if (gPeerConnection.iceGatheringState === 'complete') {
gPeerConnection.onicecandidate = iceCandidateCallback3;
// Servers changed.
- gPeerConnection.setConfiguration(
- {iceServers:[{urls:'stun:foo.invalid'}], iceTransportPolicy:'all',
- bundlePolicy:'balanced', rtcpMuxPolicy:'require', certificates:[],
- iceCandidatePoolSize:1});
+ gRtcConfig = {
+ iceServers:[
+ {
+ 'urls': ['stun:stun.invalid.scom:19302',
+ 'stun:stun.invalid2.scom:19302']
+ },
+ {
+ 'urls': ['turn:turn.invalid.udp?transport=udp'],
+ 'credential': 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
+ 'username': '28224511:1379330808'
+ },
+ {
+ 'urls': ['turn:turn.invalid.tcp?transport=tcp'],
+ 'credential': 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
+ 'username': '28224511:1379330808'
+ }
+ ],
+ iceTransportPolicy:'all',
+ bundlePolicy:'balanced',
+ rtcpMuxPolicy:'require',
+ certificates:[retrievedCertificate]
+ };
+ gPeerConnection.setConfiguration(gRtcConfig);
createOfferAndSetLocalDescription();
+ assertRtcConfigEquals(gRtcConfig, gPeerConnection.getConfiguration());
}
}
@@ -150,6 +180,38 @@
}
}
+ function assertRtcConfigEquals(config1, config2) {
+ assertEquals(config1['iceTransportPolicy'], config2['iceTransportPolicy']);
+ assertEquals(config1['bundlePolicy'], config2['bundlePolicy']);
+ assertEquals(config1['rtcpMuxPolicy'], config2['rtcpMuxPolicy']);
+ assertEquals(config1['iceServers'].length, config2['iceServers'].length);
+ for (var i in config1['iceServers']) {
+ var server1 = config1['iceServers'][i];
+ var server2 = config2['iceServers'][i];
+
+ if (!('username' in server1)) {
+ assertEquals("", server2['username']);
+ } else {
+ assertEquals(server1['username'], server2['username']);
+ }
+
+ if (!('credential' in server1)) {
+ assertEquals("", server2['credential']);
+ } else {
+ assertEquals(server1['credential'], server2['credential']);
+ }
+
+ if (!('urls' in server1)) {
+ assertEquals(0, server2['urls'].length);
+ } else {
+ assertEquals(server1['urls'].length, server2['urls'].length);
foolip 2017/03/21 08:37:14 I think this will fail due to normalization if the
+ for (var j in server1['urls']) {
+ assertEquals(server1['urls'][j], server2['urls'][j]);
+ }
+ }
+ }
+ }
+
// Helper function to create and apply offer.
function createOfferAndSetLocalDescription() {
gPeerConnection.createOffer({offerToReceiveAudio:1})

Powered by Google App Engine
This is Rietveld 408576698