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

Side by Side Diff: third_party/WebKit/LayoutTests/imagecapture/setoptions.html

Issue 2239583002: ImageCapture: support enhanced FocusMode getting/setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reillyg@ comments Created 4 years, 4 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/mock-imagecapture.js"></script> 5 <script src="resources/mock-imagecapture.js"></script>
6 <body> 6 <body>
7 <canvas id='canvas' width=10 height=10/> 7 <canvas id='canvas' width=10 height=10/>
8 </body> 8 </body>
9 <script> 9 <script>
10 10
11 const focusModeNames = ["unavailable", "manual", "single-shot", "continuous"];
12
11 // This test verifies that ImageCapture can call setOptions()s, with a mock Mojo 13 // This test verifies that ImageCapture can call setOptions()s, with a mock Mojo
12 // interface implementation. 14 // interface implementation.
13
14 async_test(function(t) { 15 async_test(function(t) {
15 var canvas = document.getElementById('canvas'); 16 var canvas = document.getElementById('canvas');
16 var context = canvas.getContext("2d"); 17 var context = canvas.getContext("2d");
17 context.fillStyle = "red"; 18 context.fillStyle = "red";
18 context.fillRect(0, 0, 10, 10); 19 context.fillRect(0, 0, 10, 10);
19 var stream = canvas.captureStream(); 20 var stream = canvas.captureStream();
20 21
21 var theMock = null; 22 var theMock = null;
22 const optionsDict = { zoom : 7, imageWidth : 1080, imageHeight : 100 }; 23 const optionsDict = { zoom : 7,
24 imageWidth : 1080,
25 imageHeight : 100,
26 focusMode : "continuous" };
23 mockImageCaptureReady 27 mockImageCaptureReady
24 .then(mock => { 28 .then(mock => {
25 theMock = mock; 29 theMock = mock;
26 return new ImageCapture(stream.getVideoTracks()[0]); 30 return new ImageCapture(stream.getVideoTracks()[0]);
27 }) 31 })
28 .catch(error => { 32 .catch(error => {
29 assert_unreached("Error creating MockImageCapture: " + error); 33 assert_unreached("Error creating MockImageCapture: " + error);
30 }) 34 })
31 .then(capturer => { 35 .then(capturer => {
32 return capturer.setOptions(optionsDict); 36 return capturer.setOptions(optionsDict);
33 }) 37 })
34 .then(function() { 38 .then(function() {
35 assert_true(theMock.options().has_zoom, 'has_zoom must be true'); 39 assert_true(theMock.options().has_zoom, 'has_zoom must be true');
36 assert_equals(optionsDict.zoom, theMock.options().zoom, 'zoom value'); 40 assert_equals(optionsDict.zoom, theMock.options().zoom, 'zoom value');
37 assert_equals(true, theMock.options().has_width, 'has_width must be true') ; 41 assert_equals(true, theMock.options().has_width, 'has_width must be true') ;
38 assert_equals(optionsDict.imageWidth, theMock.options().width, 'width valu e'); 42 assert_equals(optionsDict.imageWidth, theMock.options().width, 'width valu e');
39 assert_equals(true, theMock.options().has_height, 'has_height must be true '); 43 assert_equals(true, theMock.options().has_height, 'has_height must be true ');
40 assert_equals(optionsDict.imageHeight, theMock.options().height, 'height v alue'); 44 assert_equals(optionsDict.imageHeight, theMock.options().height, 'height v alue');
45 assert_equals(true, theMock.options().has_focus_mode, 'has_focus_mode must be true');
46 assert_equals(optionsDict.focusMode,
47 focusModeNames[theMock.options().focus_mode],
48 'focusMode value');
41 t.done(); 49 t.done();
42 }) 50 })
43 .catch(error => { 51 .catch(error => {
44 assert_unreached("Error during setOptions(): " + error); 52 assert_unreached("Error during setOptions(): " + error);
45 }); 53 });
46 }, 'exercises the ImageCapture API setOptions()'); 54 }, 'exercises the ImageCapture API setOptions()');
47 55
48 </script> 56 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698