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

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

Issue 2766473002: Image Capture: wire getSettings() from MediaStreamTrack (Closed)
Patch Set: Created 3 years, 9 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 // This test verifies that the |constraints| configured in the mock Mojo
12 // service implementation, are returned by MediaStreamTrack.getSettings().
13
14 async_test(function(t) {
15 var canvas = document.getElementById('canvas');
16 var context = canvas.getContext("2d");
17 context.fillStyle = "red";
18 context.fillRect(0, 0, 10, 10);
19
20
Reilly Grant (use Gerrit) 2017/03/21 01:25:17 nit: extra whitespace
mcasas 2017/03/21 02:40:10 Done.
21 const constraints = { advanced : [{ whiteBalanceMode : "manual",
22 exposureMode : "continuous",
23 focusMode : "single-shot",
24
25 exposureCompensation : 133.77,
26 colorTemperature : 6000,
27 iso : 120.0,
28
29 brightness : 3,
30 contrast : 4,
31 saturation : 5,
32 sharpness : 6,
33
34 zoom : 3.141592
35 // TODO: torch https://crbug.com/700607.
36 }]};
37 var theMock = null;
38 var videoTrack = null;
39 mockImageCaptureReady
40 .then(mock => {
41 theMock = mock;
42 // |stream| must be created _after_ |mock| is constructed to give the
43 // latter time to override the bindings.
44 var stream = canvas.captureStream();
45 videoTrack = stream.getVideoTracks()[0];
46
47 return videoTrack.applyConstraints(constraints);
48 })
49 .catch(error => {
Reilly Grant (use Gerrit) 2017/03/21 01:25:17 To catch just errors from mockImageCapture ready t
mcasas 2017/03/21 02:40:10 Gotcha. I got it wrong in the other mock-based tes
50 assert_unreached("Error creating MockImageCapture: " + error.message);
51 })
52 .then(function() {
53
54 settings = videoTrack.getSettings();
55 assert_equals(typeof settings, 'object');
56
57 assert_equals(constraints.advanced[0].whiteBalanceMode,
58 settings.whiteBalanceMode, 'whiteBalanceMode');
59 assert_equals(constraints.advanced[0].exposureMode, settings.exposureMode,
60 'exposureMode');
61 assert_equals(constraints.advanced[0].focusMode, settings.focusMode,
62 'focusMode');
63
64 assert_equals(constraints.advanced[0].exposureCompensation,
65 settings.exposureCompensation, 'exposure_compensation');
66 assert_equals(constraints.advanced[0].colorTemperature,
67 settings.colorTemperature, 'color_temperature');
68 assert_equals(constraints.advanced[0].iso, settings.iso, 'iso');
69
70 assert_equals(constraints.advanced[0].brightness, settings.brightness,
71 'brightness');
72 assert_equals(constraints.advanced[0].contrast, settings.contrast,
73 'contrast');
74 assert_equals(constraints.advanced[0].saturation, settings.saturation,
75 'saturation');
76 assert_equals(constraints.advanced[0].sharpness, settings.sharpness,
77 'sharpness');
78
79 assert_equals(constraints.advanced[0].zoom, settings.zoom, 'zoom');
80
81 // TODO(mcasas): check |torch| when the mojom interface is updated,
82 // https://crbug.com/700607.
83
84 t.done();
85 })
86 .catch(error => {
87 assert_unreached("Error creating MockImageCapture: " + error);
Reilly Grant (use Gerrit) 2017/03/21 01:25:17 Error applying constraints?
mcasas 2017/03/21 02:40:10 Done.
88 });
89
90 }, 'exercises an applyConstraints() - getSettings() cycle');
91
92 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698