blob: d6c5c6052aebd63eddd5584893f8834e8de37e60 [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>
const fillLightModeNames = ["off", "auto", "flash"];
// 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 = { imageWidth : 1080,
imageHeight : 100,
redEyeReduction : true,
fillLightMode : "flash"
};
mockImageCaptureReady
.then(mock => {
theMock = mock;
return new ImageCapture(stream.getVideoTracks()[0]);
},
error => {
assert_unreached("Error creating MockImageCapture: " + error);
})
.then(capturer => {
return capturer.setOptions(optionsDict);
})
.then(function() {
assert_equals(true, theMock.options().has_width, 'has_width');
assert_equals(optionsDict.imageWidth, theMock.options().width, 'width');
assert_equals(true, theMock.options().has_height, 'has_height');
assert_equals(optionsDict.imageHeight, theMock.options().height,
'height');
// Depending on how mojo boolean packing in integers is arranged, this can
// be a number instead of a boolean, compare directly.
// TODO(mcasas): Revert to assert_equals() when yzshen@ has sorted it out.
assert_true(
optionsDict.redEyeReduction == theMock.options().red_eye_reduction,
'red_eye_reduction');
assert_equals(true, theMock.options().has_fill_light_mode,
'has_fill_light_mode');
assert_equals(optionsDict.fillLightMode,
fillLightModeNames[theMock.options().fill_light_mode],
'fillLightMode');
t.done();
})
.catch(error => {
assert_unreached("Error during setOptions(): " + error.message);
});
}, 'exercises ImageCapture.setOptions(options)');
</script>