mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 1253499 - Add mochitest for live-updating scaleResolutionDownBy. r=jib
Differential Revision: https://phabricator.services.mozilla.com/D4127 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
f389699776
commit
ed6cf715a9
@ -256,6 +256,8 @@ skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulato
|
||||
[test_peerConnection_setLocalOfferInHaveRemoteOffer.html]
|
||||
[test_peerConnection_setParameters.html]
|
||||
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
|
||||
[test_peerConnection_setParameters_scaleResolutionDownBy.html]
|
||||
skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
|
||||
[test_peerConnection_setRemoteAnswerInHaveRemoteOffer.html]
|
||||
[test_peerConnection_setRemoteAnswerInStable.html]
|
||||
[test_peerConnection_setRemoteOfferInHaveLocalOffer.html]
|
||||
|
@ -0,0 +1,80 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<script type="application/javascript" src="pc.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
createHTML({
|
||||
bug: "1253499",
|
||||
title: "Live-updating scaleResolutionDownBy"
|
||||
});
|
||||
|
||||
let sender, localElem, remoteElem;
|
||||
let originalWidth, originalAspectRatio, originalScale;
|
||||
|
||||
async function checkScaleDownBy(scale) {
|
||||
sender.setParameters({ encodings: [{ scaleResolutionDownBy: scale }] });
|
||||
await haveEvent(remoteElem, "resize", wait(5000, new Error("Timeout")));
|
||||
|
||||
// Find the expected resolution. Internally we pick the closest lower
|
||||
// resolution with an identical aspect ratio.
|
||||
let expectedWidth = Math.floor(originalWidth / scale);
|
||||
while (expectedWidth / originalAspectRatio % 1 != 0) {
|
||||
--expectedWidth;
|
||||
}
|
||||
is(remoteElem.videoWidth, expectedWidth,
|
||||
`Width should have scaled down by ${scale}`);
|
||||
is(remoteElem.videoHeight, expectedWidth / originalAspectRatio,
|
||||
`Height should have scaled down by ${scale}`);
|
||||
}
|
||||
|
||||
runNetworkTest(async function (options) {
|
||||
await pushPrefs(['media.peerconnection.video.lock_scaling', true]);
|
||||
|
||||
let test = new PeerConnectionTest(options);
|
||||
test.setMediaConstraints([{video: true}], []);
|
||||
test.chain.append([
|
||||
function CHECK_PRECONDITIONS() {
|
||||
is(test.pcLocal._pc.getSenders().length, 1,
|
||||
"Should have 1 local sender");
|
||||
is(test.pcLocal.localMediaElements.length, 1,
|
||||
"Should have 1 local sending media element");
|
||||
is(test.pcRemote.remoteMediaElements.length, 1,
|
||||
"Should have 1 remote media element");
|
||||
|
||||
sender = test.pcLocal._pc.getSenders()[0];
|
||||
localElem = test.pcLocal.localMediaElements[0];
|
||||
remoteElem = test.pcRemote.remoteMediaElements[0];
|
||||
|
||||
remoteElem.addEventListener("resize", () =>
|
||||
info(`Video resized to ${remoteElem.videoWidth}x${remoteElem.videoHeight}`));
|
||||
|
||||
originalWidth = localElem.videoWidth;
|
||||
originalAspectRatio = originalWidth / localElem.videoHeight;
|
||||
originalScale = remoteElem.videoWidth / originalWidth;
|
||||
info(`Original width is ${originalWidth}`);
|
||||
},
|
||||
function PC_LOCAL_SCALEDOWNBY_2() {
|
||||
return checkScaleDownBy(2);
|
||||
},
|
||||
function PC_LOCAL_SCALEDOWNBY_4() {
|
||||
return checkScaleDownBy(4);
|
||||
},
|
||||
function PC_LOCAL_SCALEDOWNBY_15() {
|
||||
return checkScaleDownBy(15);
|
||||
},
|
||||
function PC_LOCAL_SCALEDOWNBY_8() {
|
||||
return checkScaleDownBy(8);
|
||||
},
|
||||
function PC_LOCAL_SCALEDOWNBY_1() {
|
||||
return checkScaleDownBy(1);
|
||||
},
|
||||
]);
|
||||
test.run();
|
||||
});
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user