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

Side by Side Diff: third_party/WebKit/LayoutTests/imagecapture/resources/mock-imagecapture.js

Issue 2773593004: Image Capture: prune Photo{Capabilities/Settings} and add MediaTrackConstraintSet.pointsOfInterest (Closed)
Patch Set: reillyg@ comments on idl urls. 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
1 "use strict"; 1 "use strict";
2 2
3 let mockImageCaptureReady = define( 3 let mockImageCaptureReady = define(
4 'mockImageCapture', 4 'mockImageCapture',
5 ['media/capture/mojo/image_capture.mojom', 5 ['media/capture/mojo/image_capture.mojom',
6 'mojo/public/js/bindings', 6 'mojo/public/js/bindings',
7 'content/public/renderer/interfaces', 7 'content/public/renderer/interfaces',
8 ], (imageCapture, bindings, interfaces) => { 8 ], (imageCapture, bindings, interfaces) => {
9 9
10 class MockImageCapture { 10 class MockImageCapture {
11 constructor() { 11 constructor() {
12 interfaces.addInterfaceOverrideForTesting( 12 interfaces.addInterfaceOverrideForTesting(
13 imageCapture.ImageCapture.name, 13 imageCapture.ImageCapture.name,
14 handle => this.bindingSet_.addBinding(this, handle)); 14 handle => this.bindingSet_.addBinding(this, handle));
15 15
16 this.capabilities_ = { capabilities : { 16 this.state_ = { capabilities : {
17 iso : { min : 100.0, max : 12000.0, current : 400.0, step : 1.0 }, 17 iso : { min : 100.0, max : 12000.0, current : 400.0, step : 1.0 },
18 height : { min : 240.0, max : 2448.0, current : 240.0, step : 2.0 }, 18 height : { min : 240.0, max : 2448.0, current : 240.0, step : 2.0 },
19 width : { min : 320.0, max : 3264.0, current : 320.0, step : 3.0 }, 19 width : { min : 320.0, max : 3264.0, current : 320.0, step : 3.0 },
20 zoom : { min : 0.0, max : 10.0, current : 5.0, step : 5.0 }, 20 zoom : { min : 0.0, max : 10.0, current : 5.0, step : 5.0 },
21 focus_mode : imageCapture.MeteringMode.MANUAL, 21 focus_mode : imageCapture.MeteringMode.MANUAL,
22 exposure_mode : imageCapture.MeteringMode.SINGLE_SHOT, 22 exposure_mode : imageCapture.MeteringMode.SINGLE_SHOT,
23 exposure_compensation : 23 exposure_compensation :
24 { min : -200.0, max : 200.0, current : 33.0, step : 33.0}, 24 { min : -200.0, max : 200.0, current : 33.0, step : 33.0},
25 white_balance_mode : imageCapture.MeteringMode.CONTINUOUS, 25 white_balance_mode : imageCapture.MeteringMode.CONTINUOUS,
26 fill_light_mode : imageCapture.FillLightMode.AUTO, 26 fill_light_mode : imageCapture.FillLightMode.AUTO,
27 red_eye_reduction : true, 27 red_eye_reduction : true,
28 color_temperature : 28 color_temperature :
29 { min : 2500.0, max : 6500.0, current : 6000.0, step : 1000.0 }, 29 { min : 2500.0, max : 6500.0, current : 6000.0, step : 1000.0 },
30 brightness : { min : 1.0, max : 10.0, current : 5.0, step : 1.0 }, 30 brightness : { min : 1.0, max : 10.0, current : 5.0, step : 1.0 },
31 contrast : { min : 2.0, max : 9.0, current : 5.0, step : 1.0 }, 31 contrast : { min : 2.0, max : 9.0, current : 5.0, step : 1.0 },
32 saturation : { min : 3.0, max : 8.0, current : 6.0, step : 1.0 }, 32 saturation : { min : 3.0, max : 8.0, current : 6.0, step : 1.0 },
33 sharpness : { min : 4.0, max : 7.0, current : 7.0, step : 1.0 }, 33 sharpness : { min : 4.0, max : 7.0, current : 7.0, step : 1.0 },
34 points_of_interest : [],
34 }}; 35 }};
35 this.settings_ = null; 36 this.settings_ = null;
36 this.bindingSet_ = new bindings.BindingSet(imageCapture.ImageCapture); 37 this.bindingSet_ = new bindings.BindingSet(imageCapture.ImageCapture);
37 } 38 }
38 39
39 getCapabilities(source_id) { 40 getCapabilities(source_id) {
40 return Promise.resolve(this.capabilities_); 41 return Promise.resolve(this.state_);
41 } 42 }
42 43
43 setOptions(source_id, settings) { 44 setOptions(source_id, settings) {
44 this.settings_ = settings; 45 this.settings_ = settings;
45 if (settings.has_iso) 46 if (settings.has_iso)
46 this.capabilities_.capabilities.iso.current = settings.iso; 47 this.state_.capabilities.iso.current = settings.iso;
47 if (settings.has_height) 48 if (settings.has_height)
48 this.capabilities_.capabilities.height.current = settings.height; 49 this.state_.capabilities.height.current = settings.height;
49 if (settings.has_width) 50 if (settings.has_width)
50 this.capabilities_.capabilities.width.current = settings.width; 51 this.state_.capabilities.width.current = settings.width;
51 if (settings.has_zoom) 52 if (settings.has_zoom)
52 this.capabilities_.capabilities.zoom.current = settings.zoom; 53 this.state_.capabilities.zoom.current = settings.zoom;
53 if (settings.has_focus_mode) { 54 if (settings.has_focus_mode)
54 this.capabilities_.capabilities.focus_mode = 55 this.state_.capabilities.focus_mode = settings.focus_mode;
55 settings.focus_mode; 56
57 if (settings.points_of_interest.length > 0) {
58 this.state_.capabilities.points_of_interest =
59 settings.points_of_interest;
56 } 60 }
57 if (settings.has_exposure_mode) { 61
58 this.capabilities_.capabilities.exposure_mode = 62 if (settings.has_exposure_mode)
59 settings.exposure_mode; 63 this.state_.capabilities.exposure_mode = settings.exposure_mode;
60 } 64
61 if (settings.has_exposure_compensation) { 65 if (settings.has_exposure_compensation) {
62 this.capabilities_.capabilities.exposure_compensation.current = 66 this.state_.capabilities.exposure_compensation.current =
63 settings.exposure_compensation; 67 settings.exposure_compensation;
64 } 68 }
65 if (settings.has_white_balance_mode) { 69 if (settings.has_white_balance_mode) {
66 this.capabilities_.capabilities.white_balance_mode = 70 this.state_.capabilities.white_balance_mode =
67 settings.white_balance_mode; 71 settings.white_balance_mode;
68 } 72 }
69 if (settings.has_fill_light_mode) { 73 if (settings.has_fill_light_mode)
70 this.capabilities_.capabilities.fill_light_mode = 74 this.state_.capabilities.fill_light_mode = settings.fill_light_mode;
71 settings.fill_light_mode; 75 if (settings.has_red_eye_reduction)
72 } 76 this.state_.capabilities.red_eye_reduction = settings.red_eye_reduction;
73 if (settings.has_red_eye_reduction) {
74 this.capabilities_.capabilities.red_eye_reduction =
75 settings.red_eye_reduction;
76 }
77 if (settings.has_color_temperature) { 77 if (settings.has_color_temperature) {
78 this.capabilities_.capabilities.color_temperature.current = 78 this.state_.capabilities.color_temperature.current =
79 settings.color_temperature; 79 settings.color_temperature;
80 } 80 }
81 if (settings.has_brightness) 81 if (settings.has_brightness)
82 this.capabilities_.capabilities.brightness.current = settings.brightness ; 82 this.state_.capabilities.brightness.current = settings.brightness;
83 if (settings.has_contrast) 83 if (settings.has_contrast)
84 this.capabilities_.capabilities.contrast.current = settings.contrast; 84 this.state_.capabilities.contrast.current = settings.contrast;
85 if (settings.has_saturation) { 85 if (settings.has_saturation)
86 this.capabilities_.capabilities.saturation.current = 86 this.state_.capabilities.saturation.current = settings.saturation;
87 settings.saturation;
88 }
89 if (settings.has_sharpness) 87 if (settings.has_sharpness)
90 this.capabilities_.capabilities.sharpness.current = settings.sharpness; 88 this.state_.capabilities.sharpness.current = settings.sharpness;
91 89
92 return Promise.resolve({ success : true }); 90 return Promise.resolve({ success : true });
93 } 91 }
94 92
95 takePhoto(source_id) { 93 takePhoto(source_id) {
96 return Promise.resolve({ blob : { mime_type : 'image/cat', 94 return Promise.resolve({ blob : { mime_type : 'image/cat',
97 data : new Array(2) } }); 95 data : new Array(2) } });
98 } 96 }
99 97
100 capabilities() { 98 capabilities() {
101 return this.capabilities_.capabilities; 99 return this.state_.capabilities;
102 } 100 }
103 101
104 options() { 102 options() {
105 return this.settings_; 103 return this.settings_;
106 } 104 }
107 105
108 } 106 }
109 return new MockImageCapture(); 107 return new MockImageCapture();
110 }); 108 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698