Bug 1800136: Test-cases for ICE candidate stats. r=jib

Differential Revision: https://phabricator.services.mozilla.com/D162321
This commit is contained in:
Byron Campen [:bwc] 2022-12-20 22:12:09 +00:00
Родитель 33170958b2
Коммит bdcfd5c090
2 изменённых файлов: 39 добавлений и 0 удалений

Просмотреть файл

@ -1,5 +1,6 @@
<!doctype html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>RTCRtpReceiver.prototype.getStats</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
@ -122,4 +123,23 @@
validateStatsReport(statsReportSecond);
}, 'receiver.getStats() should work with a closed PeerConnection');
promise_test(async t => {
const caller = new RTCPeerConnection();
t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const stream = await getNoiseStream({audio:true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
caller.addTrack(track, stream);
exchangeIceCandidates(caller, callee);
exchangeIceCandidates(callee, caller);
await exchangeOfferAnswer(caller, callee);
await waitForIceStateChange(caller, ['checking']);
const receiver = callee.getReceivers()[0];
const statsReport = await receiver.getStats();
assert_stats_report_has_stats(statsReport, ['candidate-pair', 'local-candidate', 'remote-candidate']);
}, 'receiver.getStats() should return stats report containing ICE candidate stats');
</script>

Просмотреть файл

@ -1,5 +1,6 @@
<!doctype html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>RTCRtpSender.prototype.getStats</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
@ -72,4 +73,22 @@
assert_stats_report_has_stats(statsReport, ['outbound-rtp']);
}, 'sender.getStats() via addTrack should return stats report containing outbound-rtp stats');
promise_test(async t => {
const caller = new RTCPeerConnection();
t.add_cleanup(() => caller.close());
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
const stream = await getNoiseStream({audio:true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track] = stream.getTracks();
const { sender } = caller.addTransceiver(track);
exchangeIceCandidates(caller, callee);
exchangeIceCandidates(callee, caller);
await exchangeOfferAnswer(caller, callee);
await waitForIceStateChange(caller, ['checking']);
const statsReport = await sender.getStats();
assert_stats_report_has_stats(statsReport, ['candidate-pair', 'local-candidate', 'remote-candidate']);
}, 'sender.getStats() should return stats report containing ICE candidate stats');
</script>