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

Side by Side Diff: third_party/WebKit/LayoutTests/imagecapture/MediaStreamTrack-applyConstraints-reject.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 var canvas = document.getElementById('canvas');
12 var context = canvas.getContext("2d");
13 context.fillStyle = "red";
14 context.fillRect(0, 0, 10, 10);
15
16 // This test verifies that MediaStreamTrack.applyConstraints() rejects if any
17 // passed constraint is unsupported or outside its allowed range.
18 var makePromiseTest = function(getConstraint) {
19 promise_test(function(t) {
20 var theMock = null;
21 var videoTrack = null;
22 return mockImageCaptureReady
23 .then(mock => {
24 theMock = mock;
25 theMock.capabilities().supports_torch = false;
26
27 var stream = canvas.captureStream();
28 videoTrack = stream.getVideoTracks()[0];
29
30 // |videoTrack|'s capabilities gathering, just like the actual capture,
31 // is a process kicked off right after creation, we introduce a small
32 // delay to allow for those to be collected, since they are needed to
33 // understand which constraints are supported in applyConstraints().
34 // TODO(mcasas): this shouldn't be needed, https://crbug.com/711524.
35 return new Promise(resolve => setTimeout(resolve, 100));
36 },
37 error => {
38 assert_unreached("Error creating MockImageCapture: " + error);
39 })
40 .then(function() {
41 const constraints = {
42 advanced : [ getConstraint(theMock.capabilities()) ]
43 };
44 return promise_rejects(t, "NotSupportedError",
45 videoTrack.applyConstraints(constraints));
46 });
47 });
48 };
49
50 const constraintGenerators = [
51 (capabilities) => { return { whiteBalanceMode : "manual" }; },
52 (capabilities) => { return { exposureMode : "manual" }; },
53 (capabilities) => { return { focusMode : "continuous" }; },
54 (capabilities) => {
55 return {
56 exposureCompensation : capabilities.exposure_compensation.max + 1
57 };
58 },
59 (capabilities) => {
60 return {
61 exposureCompensation : capabilities.exposure_compensation.min - 1
62 };
63 },
64 (capabilities) => {
65 return { colorTemperature : capabilities.color_temperature.max + 1 };
66 },
67 (capabilities) => {
68 return { colorTemperature : capabilities.color_temperature.min - 1 };
69 },
70 (capabilities) => { return { iso : capabilities.iso.max + 1 }; },
71 (capabilities) => { return { iso : capabilities.iso.min - 1 }; },
72 (capabilities) => {
73 return { brightness : capabilities.brightness.max + 1 };
74 },
75 (capabilities) => {
76 return { brightness : capabilities.brightness.min - 1 };
77 },
78 (capabilities) => { return { contrast : capabilities.contrast.max + 1 }; },
79 (capabilities) => { return { contrast : capabilities.contrast.min - 1 }; },
80 (capabilities) => { return {
81 saturation : capabilities.saturation.max + 1 };
82 },
83 (capabilities) => {
84 return { saturation : capabilities.saturation.min - 1 };
85 },
86 (capabilities) => { return { sharpness : capabilities.sharpness.max + 1 }; },
87 (capabilities) => { return { sharpness : capabilities.sharpness.min - 1 }; },
88 (capabilities) => { return { zoom : capabilities.zoom.max + 1 }; },
89 (capabilities) => { return { zoom : capabilities.zoom.min - 1 }; },
90 (capabilities) => { return { torch : true }; },
91 ];
92
93 for (key in constraintGenerators) {
94 generate_tests(
95 makePromiseTest, [[
96 'MediaStreamTrack.applyConstraints(constraints) rejects with bad' +
97 ' constraints, #' + key,
98 constraintGenerators[key]
99 ]]);
100 }
101
102 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698