| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright 2017 The Chromium Authors. All rights reserved. | 2 * Copyright 2017 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 // Public interface to tests. These are expected to be called with | 7 // Public interface to tests. These are expected to be called with |
| 8 // ExecuteJavascript invocations from the browser tests and will return answers | 8 // ExecuteJavascript invocations from the browser tests and will return answers |
| 9 // through the DOM automation controller. | 9 // through the DOM automation controller. |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 }, | 23 }, |
| 24 function(error) { | 24 function(error) { |
| 25 throw failTest('getUserMedia failed: ' + error); | 25 throw failTest('getUserMedia failed: ' + error); |
| 26 }); | 26 }); |
| 27 } else { | 27 } else { |
| 28 returnToTest('ok-streams-created-and-added'); | 28 returnToTest('ok-streams-created-and-added'); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Verifies that the peer connection's getSenders() returns one sender per local |
| 34 * track, that there are no duplicates and that object identity is preserved. |
| 35 * |
| 36 * Returns "ok-senders-verified" on success. |
| 37 */ |
| 38 function verifyRtpSenders(expectedNumTracks = null) { |
| 39 if (expectedNumTracks != null && |
| 40 peerConnection_().getSenders().length != expectedNumTracks) { |
| 41 throw failTest('getSenders().length != expectedNumTracks'); |
| 42 } |
| 43 if (!arrayEquals_(peerConnection_().getSenders(), |
| 44 peerConnection_().getSenders())) { |
| 45 throw failTest('One getSenders() call is not equal to the next.'); |
| 46 } |
| 47 |
| 48 let localTracks = new Set(); |
| 49 peerConnection_().getLocalStreams().forEach(function(stream) { |
| 50 stream.getTracks().forEach(function(track) { |
| 51 localTracks.add(track); |
| 52 }); |
| 53 }); |
| 54 if (peerConnection_().getSenders().length != localTracks.size) |
| 55 throw failTest('The number of senders and tracks are not the same.'); |
| 56 |
| 57 let senders = new Set(); |
| 58 let senderTracks = new Set(); |
| 59 peerConnection_().getSenders().forEach(function(sender) { |
| 60 if (sender == null) |
| 61 throw failTest('sender is null or undefined.'); |
| 62 if (sender.track == null) |
| 63 throw failTest('sender.track is null or undefined.'); |
| 64 senders.add(sender); |
| 65 senderTracks.add(sender.track); |
| 66 }); |
| 67 if (senderTracks.size != senders.size) |
| 68 throw failTest('senderTracks.size != senders.size'); |
| 69 |
| 70 if (!setEquals_(senderTracks, localTracks)) { |
| 71 throw failTest('The set of sender tracks is not equal to the set of ' + |
| 72 'stream tracks.'); |
| 73 } |
| 74 returnToTest('ok-senders-verified'); |
| 75 } |
| 76 |
| 77 /** |
| 33 * Verifies that the peer connection's getReceivers() returns one receiver per | 78 * Verifies that the peer connection's getReceivers() returns one receiver per |
| 34 * remote track, that there are no duplicates and that object identity is | 79 * remote track, that there are no duplicates and that object identity is |
| 35 * preserved. | 80 * preserved. |
| 36 * | 81 * |
| 37 * Returns "ok-receivers-verified" on success. | 82 * Returns "ok-receivers-verified" on success. |
| 38 */ | 83 */ |
| 39 function verifyRtpReceivers(expectedNumTracks = null) { | 84 function verifyRtpReceivers(expectedNumTracks = null) { |
| 40 if (peerConnection_().getReceivers() == null) | 85 if (peerConnection_().getReceivers() == null) |
| 41 throw failTest('getReceivers() returns null or undefined.'); | 86 throw failTest('getReceivers() returns null or undefined.'); |
| 42 if (expectedNumTracks != null && | 87 if (expectedNumTracks != null && |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 if (a == null) | 144 if (a == null) |
| 100 return b == null; | 145 return b == null; |
| 101 if (a.size != b.size) | 146 if (a.size != b.size) |
| 102 return false; | 147 return false; |
| 103 a.forEach(function(value) { | 148 a.forEach(function(value) { |
| 104 if (!b.has(value)) | 149 if (!b.has(value)) |
| 105 return false; | 150 return false; |
| 106 }); | 151 }); |
| 107 return true; | 152 return true; |
| 108 } | 153 } |
| OLD | NEW |