test_peerConnection_verifyAudioAfterRenegotiation.html (4076B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="pc.js"></script> 5 </head> 6 <body> 7 <pre id="test"> 8 <script type="application/javascript"> 9 createHTML({ 10 bug: "1166832", 11 title: "Renegotiation: verify audio after renegotiation" 12 }); 13 14 runNetworkTest(function (options) { 15 const test = new PeerConnectionTest(options); 16 const helper = new AudioStreamFlowingHelper(); 17 18 test.chain.append([ 19 function CHECK_ASSUMPTIONS() { 20 is(test.pcLocal.localMediaElements.length, 1, 21 "pcLocal should have one media element"); 22 is(test.pcRemote.remoteMediaElements.length, 1, 23 "pcRemote should have one media element"); 24 is(test.pcLocal._pc.getLocalStreams().length, 1, 25 "pcLocal should have one stream"); 26 is(test.pcRemote._pc.getRemoteStreams().length, 1, 27 "pcRemote should have one stream"); 28 }, 29 function CHECK_AUDIO() { 30 return Promise.resolve() 31 .then(() => info("Checking local audio enabled")) 32 .then(() => helper.checkAudioFlowing(test.pcLocal._pc.getLocalStreams()[0])) 33 .then(() => info("Checking remote audio enabled")) 34 .then(() => helper.checkAudioFlowing(test.pcRemote._pc.getRemoteStreams()[0])) 35 36 .then(() => test.pcLocal._pc.getLocalStreams()[0].getAudioTracks()[0].enabled = false) 37 38 .then(() => info("Checking local audio disabled")) 39 .then(() => helper.checkAudioNotFlowing(test.pcLocal._pc.getLocalStreams()[0])) 40 .then(() => info("Checking remote audio disabled")) 41 .then(() => helper.checkAudioNotFlowing(test.pcRemote._pc.getRemoteStreams()[0])) 42 } 43 ]); 44 45 addRenegotiation(test.chain, 46 [ 47 function PC_LOCAL_ADD_SECOND_STREAM(test) { 48 test.setMediaConstraints([{audio: true}], 49 []); 50 return test.pcLocal.getAllUserMediaAndAddStreams([{audio: true}]); 51 }, 52 ] 53 ); 54 55 test.chain.append([ 56 function CHECK_ASSUMPTIONS2() { 57 is(test.pcLocal.localMediaElements.length, 2, 58 "pcLocal should have two media elements"); 59 is(test.pcRemote.remoteMediaElements.length, 2, 60 "pcRemote should have two media elements"); 61 is(test.pcLocal._pc.getLocalStreams().length, 2, 62 "pcLocal should have two streams"); 63 is(test.pcRemote._pc.getRemoteStreams().length, 2, 64 "pcRemote should have two streams"); 65 }, 66 function RE_CHECK_AUDIO() { 67 return Promise.resolve() 68 .then(() => info("Checking local audio enabled")) 69 .then(() => helper.checkAudioNotFlowing(test.pcLocal._pc.getLocalStreams()[0])) 70 .then(() => info("Checking remote audio enabled")) 71 .then(() => helper.checkAudioNotFlowing(test.pcRemote._pc.getRemoteStreams()[0])) 72 73 .then(() => info("Checking local2 audio enabled")) 74 .then(() => helper.checkAudioFlowing(test.pcLocal._pc.getLocalStreams()[1])) 75 .then(() => info("Checking remote2 audio enabled")) 76 .then(() => helper.checkAudioFlowing(test.pcRemote._pc.getRemoteStreams()[1])) 77 78 .then(() => test.pcLocal._pc.getLocalStreams()[1].getAudioTracks()[0].enabled = false) 79 .then(() => test.pcLocal._pc.getLocalStreams()[0].getAudioTracks()[0].enabled = true) 80 81 .then(() => info("Checking local2 audio disabled")) 82 .then(() => helper.checkAudioNotFlowing(test.pcLocal._pc.getLocalStreams()[1])) 83 .then(() => info("Checking remote2 audio disabled")) 84 .then(() => helper.checkAudioNotFlowing(test.pcRemote._pc.getRemoteStreams()[1])) 85 86 .then(() => info("Checking local audio enabled")) 87 .then(() => helper.checkAudioFlowing(test.pcLocal._pc.getLocalStreams()[0])) 88 .then(() => info("Checking remote audio enabled")) 89 .then(() => helper.checkAudioFlowing(test.pcRemote._pc.getRemoteStreams()[0])) 90 } 91 ]); 92 93 test.setMediaConstraints([{audio: true}], []); 94 return test.run(); 95 }); 96 </script> 97 </pre> 98 </body> 99 </html>