| Index: third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints-reject.html
|
| diff --git a/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints-reject.html b/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints-reject.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f020163e9030a073adeda8b305a65446375c2469
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints-reject.html
|
| @@ -0,0 +1,102 @@
|
| +<!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>
|
| +
|
| +var canvas = document.getElementById('canvas');
|
| +var context = canvas.getContext("2d");
|
| +context.fillStyle = "red";
|
| +context.fillRect(0, 0, 10, 10);
|
| +
|
| +// This test verifies that MediaStreamTrack.applyConstraints() rejects if any
|
| +// passed constraint is unsupported or outside its allowed range.
|
| +var makePromiseTest = function(getConstraint) {
|
| + promise_test(function(t) {
|
| + var theMock = null;
|
| + var videoTrack = null;
|
| + return mockImageCaptureReady
|
| + .then(mock => {
|
| + theMock = mock;
|
| + theMock.capabilities().supports_torch = false;
|
| +
|
| + var stream = canvas.captureStream();
|
| + videoTrack = stream.getVideoTracks()[0];
|
| +
|
| + // |videoTrack|'s capabilities gathering, just like the actual capture,
|
| + // is a process kicked off right after creation, we introduce a small
|
| + // delay to allow for those to be collected, since they are needed to
|
| + // understand which constraints are supported in applyConstraints().
|
| + // TODO(mcasas): this shouldn't be needed, https://crbug.com/711524.
|
| + return new Promise(resolve => setTimeout(resolve, 100));
|
| + },
|
| + error => {
|
| + assert_unreached("Error creating MockImageCapture: " + error);
|
| + })
|
| + .then(function() {
|
| + const constraints = {
|
| + advanced : [ getConstraint(theMock.capabilities()) ]
|
| + };
|
| + return promise_rejects(t, "NotSupportedError",
|
| + videoTrack.applyConstraints(constraints));
|
| + });
|
| + });
|
| +};
|
| +
|
| +const constraintGenerators = [
|
| + (capabilities) => { return { whiteBalanceMode : "manual" }; },
|
| + (capabilities) => { return { exposureMode : "manual" }; },
|
| + (capabilities) => { return { focusMode : "continuous" }; },
|
| + (capabilities) => {
|
| + return {
|
| + exposureCompensation : capabilities.exposure_compensation.max + 1
|
| + };
|
| + },
|
| + (capabilities) => {
|
| + return {
|
| + exposureCompensation : capabilities.exposure_compensation.min - 1
|
| + };
|
| + },
|
| + (capabilities) => {
|
| + return { colorTemperature : capabilities.color_temperature.max + 1 };
|
| + },
|
| + (capabilities) => {
|
| + return { colorTemperature : capabilities.color_temperature.min - 1 };
|
| + },
|
| + (capabilities) => { return { iso : capabilities.iso.max + 1 }; },
|
| + (capabilities) => { return { iso : capabilities.iso.min - 1 }; },
|
| + (capabilities) => {
|
| + return { brightness : capabilities.brightness.max + 1 };
|
| + },
|
| + (capabilities) => {
|
| + return { brightness : capabilities.brightness.min - 1 };
|
| + },
|
| + (capabilities) => { return { contrast : capabilities.contrast.max + 1 }; },
|
| + (capabilities) => { return { contrast : capabilities.contrast.min - 1 }; },
|
| + (capabilities) => { return {
|
| + saturation : capabilities.saturation.max + 1 };
|
| + },
|
| + (capabilities) => {
|
| + return { saturation : capabilities.saturation.min - 1 };
|
| + },
|
| + (capabilities) => { return { sharpness : capabilities.sharpness.max + 1 }; },
|
| + (capabilities) => { return { sharpness : capabilities.sharpness.min - 1 }; },
|
| + (capabilities) => { return { zoom : capabilities.zoom.max + 1 }; },
|
| + (capabilities) => { return { zoom : capabilities.zoom.min - 1 }; },
|
| + (capabilities) => { return { torch : true }; },
|
| +];
|
| +
|
| +for (key in constraintGenerators) {
|
| + generate_tests(
|
| + makePromiseTest, [[
|
| + 'MediaStreamTrack.applyConstraints(constraints) rejects with bad' +
|
| + ' constraints, #' + key,
|
| + constraintGenerators[key]
|
| + ]]);
|
| +}
|
| +
|
| +</script>
|
|
|