| Index: third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints.html
|
| diff --git a/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints.html b/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..06b47dc7d4c7fd5948e762e1a10f8803b4476a2d
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints.html
|
| @@ -0,0 +1,87 @@
|
| +<!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 meteringModeNames = ["none", "manual", "single-shot", "continuous"];
|
| +const fillLightModeNames = ["none", "off", "auto", "flash", "torch"];
|
| +
|
| +// This test verifies that we can all MediaStreamTrack.applyConstraints(), with
|
| +// a mock Mojo service implementation.
|
| +
|
| +async_test(function(t) {
|
| + var canvas = document.getElementById('canvas');
|
| + var context = canvas.getContext("2d");
|
| + context.fillStyle = "red";
|
| + context.fillRect(0, 0, 10, 10);
|
| +
|
| + const constraints = { advanced : [{ whiteBalanceMode : "manual",
|
| + exposureMode : "continuous",
|
| + focusMode : "single-shot",
|
| +
|
| + exposureCompensation : 133.77,
|
| + colorTemperature : 6000,
|
| + iso : 120.0,
|
| +
|
| + brightness : 3,
|
| + contrast : 4,
|
| + saturation : 5,
|
| + sharpness : 6,
|
| +
|
| + zoom : 3.141592
|
| + // TODO: torch https://crbug.com/700607.
|
| + }]};
|
| +
|
| + var theMock = null;
|
| + mockImageCaptureReady
|
| + .then(mock => {
|
| + theMock = mock;
|
| + var stream = canvas.captureStream();
|
| + var videoTrack = stream.getVideoTracks()[0];
|
| +
|
| + return videoTrack.applyConstraints(constraints);
|
| + })
|
| + .catch(error => {
|
| + assert_unreached("Error creating MockImageCapture: " + error.message);
|
| + })
|
| + .then(function() {
|
| + assert_equals(constraints.advanced[0].whiteBalanceMode,
|
| + meteringModeNames[theMock.options().white_balance_mode],
|
| + 'whiteBalanceMode');
|
| + assert_equals(constraints.advanced[0].exposureMode,
|
| + meteringModeNames[theMock.options().exposure_mode],
|
| + 'exposureMode');
|
| + assert_equals(constraints.advanced[0].focusMode,
|
| + meteringModeNames[theMock.options().focus_mode],
|
| + 'focusMode');
|
| +
|
| + assert_equals(constraints.advanced[0].exposureCompensation,
|
| + theMock.options().exposure_compensation,
|
| + 'exposure_compensation');
|
| + assert_equals(constraints.advanced[0].colorTemperature,
|
| + theMock.options().color_temperature, 'color_temperature');
|
| + assert_equals(constraints.advanced[0].iso, theMock.options().iso, 'iso');
|
| +
|
| + assert_equals(constraints.advanced[0].brightness,
|
| + theMock.options().brightness, 'brightness value');
|
| + assert_equals(constraints.advanced[0].contrast,
|
| + theMock.options().contrast, 'constrast value');
|
| + assert_equals(constraints.advanced[0].saturation,
|
| + theMock.options().saturation, 'saturation value');
|
| + assert_equals(constraints.advanced[0].sharpness,
|
| + theMock.options().sharpness, 'sharpness value');
|
| +
|
| + t.done();
|
| + })
|
| + .catch(error => {
|
| + assert_unreached("applyConstraints(): " + error.message);
|
| + })
|
| +
|
| +}, 'exercises MediaStreamTrack.applyConstraints(constraints)');
|
| +
|
| +</script>
|
|
|