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

Unified Diff: third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html

Issue 2866053002: Image Capture: teach takePhoto() to accept an optional PhotoSettings dictionary (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/imagecapture/ImageCapture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html
diff --git a/third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html b/third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html
new file mode 100644
index 0000000000000000000000000000000000000000..86bfea5893fe9e457161158e1770e7eef08fdab1
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imagecapture/takephoto-with-photosettings.html
@@ -0,0 +1,71 @@
+<!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 takePhoto with a PhotoSettings
+// argument, 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.takePhoto(optionsDict);
+ })
+ .then(blob => {
+ // JS Blob is almost-opaque, can only check |type| and |size|.
+ assert_equals(blob.type, 'image/cat');
+ assert_equals(blob.size, 2);
+
+ 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 takePhoto(): " + error.message);
+ });
+}, 'exercises ImageCapture.takePhoto(PhotoSettings dictionary)');
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/imagecapture/ImageCapture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698