blob: f6d32a038ee0ebc1504906dbb77a88eeb6b5255a [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/mojo-helpers.js"></script>
<script src="resources/mock-imagecapture.js"></script>
<body>
<canvas id='canvas' width=10 height=10/>
</body>
<script>
// This test verifies that ImageCapture can call setOptions()s, with a mock Mojo
// interface implementation.
async_test(function(t) {
var canvas = document.getElementById('canvas');
var context = canvas.getContext("2d");
context.fillStyle = "red";
context.fillRect(0, 0, 10, 10);
var stream = canvas.captureStream();
var theMock = null;
const optionsDict = { zoom : 7, imageWidth : 1080, imageHeight : 100 };
mockImageCaptureReady
.then(mock => {
theMock = mock;
return new ImageCapture(stream.getVideoTracks()[0]);
})
.catch(error => {
assert_unreached("Error creating MockImageCapture: " + error);
})
.then(capturer => {
return capturer.setOptions(optionsDict);
})
.then(function() {
assert_true(theMock.options().has_zoom, 'has_zoom must be true');
assert_equals(optionsDict.zoom, theMock.options().zoom, 'zoom value');
assert_equals(true, theMock.options().has_width, 'has_width must be true');
assert_equals(optionsDict.imageWidth, theMock.options().width, 'width value');
assert_equals(true, theMock.options().has_height, 'has_height must be true');
assert_equals(optionsDict.imageHeight, theMock.options().height, 'height value');
t.done();
})
.catch(error => {
assert_unreached("Error during setOptions(): " + error);
});
}, 'exercises the ImageCapture API setOptions()');
</script>