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

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: reverted renaming bc it breaks patching 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 => ({ whiteBalanceMode: "manual" }),
52 capabilities => ({ exposureMode: "manual" }),
53 capabilities => ({ focusMode: "continuous" }),
54 capabilities => ({
55 exposureCompensation: capabilities.exposure_compensation.max + 1
56 }),
57 capabilities => ({
58 exposureCompensation: capabilities.exposure_compensation.min - 1
59 }),
60 capabilities => ({
61 colorTemperature: capabilities.color_temperature.max + 1
62 }),
63 capabilities => ({
64 colorTemperature: capabilities.color_temperature.min - 1
65 }),
66 capabilities => ({ iso: capabilities.iso.max + 1 }),
67 capabilities => ({ iso: capabilities.iso.min - 1 }),
68 capabilities => ({ brightness: capabilities.brightness.max + 1 }),
69 capabilities => ({ brightness: capabilities.brightness.min - 1 }),
70 capabilities => ({ contrast: capabilities.contrast.max + 1 }),
71 capabilities => ({ contrast: capabilities.contrast.min - 1 }),
72 capabilities => ({ saturation: capabilities.saturation.max + 1 }),
73 capabilities => ({ saturation: capabilities.saturation.min - 1 }),
74 capabilities => ({ sharpness: capabilities.sharpness.max + 1 }),
75 capabilities => ({ sharpness: capabilities.sharpness.min - 1 }),
76 capabilities => ({ zoom: capabilities.zoom.max + 1 }),
77 capabilities => ({ zoom: capabilities.zoom.min - 1 }),
78 capabilities => ({ torch: true }),
79 ];
80
81 for (key in constraintGenerators) {
82 generate_tests(
83 makePromiseTest, [[
84 'MediaStreamTrack.applyConstraints(constraints) rejects with bad' +
85 ' constraints, #' + key,
86 constraintGenerators[key]
87 ]]);
88 }
89
90 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698