зеркало из https://github.com/mozilla/gecko-dev.git
71 строка
2.7 KiB
HTML
71 строка
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/mediacapture-image/resources/imagecapture-helpers.js"></script>
|
|
<body>
|
|
<canvas id='canvas' width=10 height=10/>
|
|
</body>
|
|
<script>
|
|
|
|
const meteringModeNames = ['none', 'manual', 'single-shot', 'continuous'];
|
|
|
|
// This test verifies that the settings defined in the mock Mojo service
|
|
// implementation are the same as those returned by the corresponding
|
|
// MediaStreamTrack.getSettings().
|
|
|
|
image_capture_test(async (t, imageCaptureTest) => {
|
|
let canvas = document.getElementById('canvas');
|
|
let context = canvas.getContext('2d');
|
|
context.fillStyle = 'red';
|
|
context.fillRect(0, 0, 10, 10);
|
|
|
|
let mockSettings = imageCaptureTest.mockImageCapture().state();
|
|
|
|
// |stream| must be created _after_ |mock| is constructed to give the
|
|
// latter time to override the bindings.
|
|
let stream = canvas.captureStream();
|
|
let videoTrack = stream.getVideoTracks()[0];
|
|
|
|
// |videoTrack|s settings retrieval, just like the actual capture, is a
|
|
// process kicked right after creation, we introduce a small delay to
|
|
// allow for those to be collected.
|
|
await new Promise(resolve => step_timeout(resolve, 100));
|
|
|
|
let settings = videoTrack.getSettings();
|
|
assert_equals(typeof settings, 'object');
|
|
|
|
assert_equals(settings.whiteBalanceMode,
|
|
meteringModeNames[mockSettings.currentWhiteBalanceMode],
|
|
'whiteBalanceMode');
|
|
assert_equals(settings.exposureMode,
|
|
meteringModeNames[mockSettings.currentExposureMode],
|
|
'exposureMode;');
|
|
assert_equals(settings.focusMode,
|
|
meteringModeNames[mockSettings.currentFocusMode],
|
|
'focusMode');
|
|
|
|
assert_point2d_array_approx_equals(
|
|
settings.pointsOfInterest, mockSettings.pointsOfInterest, 0.01);
|
|
|
|
assert_equals(settings.exposureCompensation,
|
|
mockSettings.exposureCompensation.current);
|
|
assert_equals(settings.exposureTime,
|
|
mockSettings.exposureTime.current);
|
|
assert_equals(settings.colorTemperature,
|
|
mockSettings.colorTemperature.current);
|
|
assert_equals(settings.iso, mockSettings.iso.current);
|
|
|
|
assert_equals(settings.brightness, mockSettings.brightness.current);
|
|
assert_equals(settings.contrast, mockSettings.contrast.current);
|
|
assert_equals(settings.saturation, mockSettings.saturation.current);
|
|
assert_equals(settings.sharpness, mockSettings.sharpness.current);
|
|
|
|
assert_equals(settings.focusDistance, mockSettings.focusDistance.current);
|
|
assert_equals(settings.zoom, mockSettings.zoom.current);
|
|
|
|
assert_equals(settings.torch, mockSettings.torch, 'torch');
|
|
|
|
}, 'exercises MediaStreamTrack.getSettings()');
|
|
|
|
</script>
|