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

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

Issue 2877273002: Image Capture: reject setOptions()/applyConstraints() if any argument is unsupported (Closed)
Patch Set: cleanup 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/mock-imagecapture.js"></script>
6 <body>
7 <canvas id='canvas' width=10 height=10/>
8 </body>
9 <script>
10
11 const fillLightModeNames = ["off", "auto", "flash"];
12
13 // This test verifies that ImageCapture can call takePhoto with a PhotoSettings
14 // argument, with a mock Mojo interface implementation.
15
16 async_test(function(t) {
17 var canvas = document.getElementById('canvas');
18 var context = canvas.getContext("2d");
19 context.fillStyle = "red";
20 context.fillRect(0, 0, 10, 10);
21 var stream = canvas.captureStream();
22
23 var theMock = null;
24 const optionsDict = { imageWidth : 1080,
25 imageHeight : 100,
26 redEyeReduction : true,
27 fillLightMode : "flash"
28 };
29 mockImageCaptureReady
30 .then(mock => {
31 theMock = mock;
32 return new ImageCapture(stream.getVideoTracks()[0]);
33 },
34 error => {
35 assert_unreached("Error creating MockImageCapture: " + error);
36 })
37 .then(capturer => {
38 return capturer.takePhoto(optionsDict);
39 })
40 .then(blob => {
41 // JS Blob is almost-opaque, can only check |type| and |size|.
42 assert_equals(blob.type, 'image/cat');
43 assert_equals(blob.size, 2);
44
45 assert_equals(true, theMock.options().has_width, 'has_width');
46 assert_equals(optionsDict.imageWidth, theMock.options().width, 'width');
47 assert_equals(true, theMock.options().has_height, 'has_height');
48 assert_equals(optionsDict.imageHeight, theMock.options().height,
49 'height');
50
51 // Depending on how mojo boolean packing in integers is arranged, this can
52 // be a number instead of a boolean, compare directly.
53 // TODO(mcasas): Revert to assert_equals() when yzshen@ has sorted it out.
54 assert_true(
55 optionsDict.redEyeReduction == theMock.options().red_eye_reduction,
56 'red_eye_reduction');
57
58 assert_equals(true, theMock.options().has_fill_light_mode,
59 'has_fill_light_mode');
60 assert_equals(optionsDict.fillLightMode,
61 fillLightModeNames[theMock.options().fill_light_mode],
62 'fillLightMode');
63
64 t.done();
65 })
66 .catch(error => {
67 assert_unreached("Error during takePhoto(): " + error.message);
68 });
69 }, 'exercises ImageCapture.takePhoto(PhotoSettings dictionary)');
70
71 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698