Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-getSettings.html

Issue 2766473002: Image Capture: wire getSettings() from MediaStreamTrack (Closed)
Patch Set: reillyg@s comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-getSettings.html
diff --git a/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-getSettings.html b/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-getSettings.html
new file mode 100644
index 0000000000000000000000000000000000000000..c81c4dc8206fff4f5471f6e39818c16d2e5b65e5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-getSettings.html
@@ -0,0 +1,74 @@
+<!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 the settings defined in the mock Mojo service
+// implementation are the same as those returned by the corresponding
+// MediaStreamTrack.getSettings().
+
+async_test(function(t) {
+ var canvas = document.getElementById('canvas');
+ var context = canvas.getContext("2d");
+ context.fillStyle = "red";
+ context.fillRect(0, 0, 10, 10);
+
+ var mock_settings;
+ mockImageCaptureReady
+ .then(mock => {
+ mock_settings = mock.capabilities();
+
+ // |stream| must be created _after_ |mock| is constructed to give the
+ // latter time to override the bindings.
+ var stream = canvas.captureStream();
+ var 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.
+ setTimeout(() => {
+ settings = videoTrack.getSettings();
+ assert_equals(typeof settings, 'object');
+
+ assert_equals(settings.whiteBalanceMode,
+ meteringModeNames[mock_settings.white_balance_mode],
+ 'whiteBalanceMode');
+ assert_equals(settings.exposureMode,
+ meteringModeNames[mock_settings.exposure_mode], 'exposureMode;');
+ assert_equals(settings.focusMode,
+ meteringModeNames[mock_settings.focus_mode], 'focusMode');
+
+ assert_equals(settings.exposureCompensation,
+ mock_settings.exposure_compensation.current);
+ assert_equals(settings.colorTemperature,
+ mock_settings.color_temperature.current);
+ assert_equals(settings.iso, mock_settings.iso.current);
+
+ assert_equals(settings.brightness, mock_settings.brightness.current);
+ assert_equals(settings.contrast, mock_settings.contrast.current);
+ assert_equals(settings.saturation, mock_settings.saturation.current);
+ assert_equals(settings.sharpness, mock_settings.sharpness.current);
+
+ assert_equals(settings.zoom, mock_settings.zoom.current);
+
+ // TODO(mcasas): check |torch| when the mojom interface is updated,
+ // https://crbug.com/700607.
+
+ t.done();
+ }, 100);
+ },
+ error => {
+ assert_unreached("Error creating MockImageCapture: " + error);
+ });
+
+}, 'exercises MediaStreamTrack.getSettings()');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698