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

Side by Side Diff: third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints.html

Issue 2819233002: Image Capture: Reject applyConstraints() if passed an unsupported constraint (Closed)
Patch Set: Created 3 years, 8 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
(...skipping 23 matching lines...) Expand all
34 contrast : 4, 34 contrast : 4,
35 saturation : 5, 35 saturation : 5,
36 sharpness : 6, 36 sharpness : 6,
37 37
38 zoom : 3.141592, 38 zoom : 3.141592,
39 39
40 torch : true 40 torch : true
41 }]}; 41 }]};
42 42
43 var theMock = null; 43 var theMock = null;
44 var videoTrack = null;
44 mockImageCaptureReady 45 mockImageCaptureReady
45 .then(mock => { 46 .then(mock => {
46 theMock = mock; 47 theMock = mock;
47 var stream = canvas.captureStream(); 48 var stream = canvas.captureStream();
48 var videoTrack = stream.getVideoTracks()[0]; 49 videoTrack = stream.getVideoTracks()[0];
49 50
50 return videoTrack.applyConstraints(constraints); 51 // |videoTrack|'s capabilities gathering, just like the actual capture, is
52 // a process kicked off right after creation, we introduce a small delay
53 // to allow for those to be collected, since they are needed to understand
54 // which constraints are supported in applyConstraints().
55 // TODO(mcasas): this shouldn't be needed, https://crbug.com/711524.
56 return new Promise(resolve => setTimeout(resolve, 100));
51 }, 57 },
52 error => { 58 error => {
53 assert_unreached("Error creating MockImageCapture: " + error); 59 assert_unreached("Error creating MockImageCapture: " + error);
54 }) 60 })
55 .then(function() { 61 .then(function() {
62 return videoTrack.applyConstraints(constraints);
63 })
64 .then(function() {
56 assert_equals(constraints.advanced[0].whiteBalanceMode, 65 assert_equals(constraints.advanced[0].whiteBalanceMode,
57 meteringModeNames[theMock.options().white_balance_mode], 66 meteringModeNames[theMock.options().white_balance_mode],
58 'whiteBalanceMode'); 67 'whiteBalanceMode');
59 assert_equals(constraints.advanced[0].exposureMode, 68 assert_equals(constraints.advanced[0].exposureMode,
60 meteringModeNames[theMock.options().exposure_mode], 69 meteringModeNames[theMock.options().exposure_mode],
61 'exposureMode'); 70 'exposureMode');
62 assert_equals(constraints.advanced[0].focusMode, 71 assert_equals(constraints.advanced[0].focusMode,
63 meteringModeNames[theMock.options().focus_mode], 72 meteringModeNames[theMock.options().focus_mode],
64 'focusMode'); 73 'focusMode');
65 74
(...skipping 30 matching lines...) Expand all
96 105
97 t.done(); 106 t.done();
98 }) 107 })
99 .catch(error => { 108 .catch(error => {
100 assert_unreached("applyConstraints(): " + error.message); 109 assert_unreached("applyConstraints(): " + error.message);
101 }) 110 })
102 111
103 }, 'exercises MediaStreamTrack.applyConstraints(constraints)'); 112 }, 'exercises MediaStreamTrack.applyConstraints(constraints)');
104 113
105 </script> 114 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698