OLD | NEW |
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 'mojo/public/js/connection', |
7 'content/public/renderer/interfaces', | 8 'content/public/renderer/interfaces', |
8 ], (imageCapture, bindings, interfaces) => { | 9 ], (imageCapture, bindings, connection, interfaces) => { |
9 | 10 |
10 class MockImageCapture { | 11 class MockImageCapture { |
11 constructor() { | 12 constructor() { |
12 interfaces.addInterfaceOverrideForTesting( | 13 interfaces.addInterfaceOverrideForTesting( |
13 imageCapture.ImageCapture.name, | 14 imageCapture.ImageCapture.name, |
14 handle => this.bindingSet_.addBinding(this, handle)); | 15 pipe => this.bindToPipe(pipe)); |
15 | 16 |
16 this.capabilities_ = { capabilities : { | 17 this.capabilities_ = { capabilities : { |
17 iso : { min : 100.0, max : 12000.0, current : 400.0, step : 1.0 }, | 18 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 }, | 19 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 }, | 20 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 }, | 21 zoom : { min : 0.0, max : 10.0, current : 5.0, step : 5.0 }, |
21 focus_mode : imageCapture.MeteringMode.MANUAL, | 22 focus_mode : imageCapture.MeteringMode.MANUAL, |
22 exposure_mode : imageCapture.MeteringMode.SINGLE_SHOT, | 23 exposure_mode : imageCapture.MeteringMode.SINGLE_SHOT, |
23 exposure_compensation : | 24 exposure_compensation : |
24 { min : -200.0, max : 200.0, current : 33.0, step : 33.0}, | 25 { min : -200.0, max : 200.0, current : 33.0, step : 33.0}, |
25 white_balance_mode : imageCapture.MeteringMode.CONTINUOUS, | 26 white_balance_mode : imageCapture.MeteringMode.CONTINUOUS, |
26 fill_light_mode : imageCapture.FillLightMode.AUTO, | 27 fill_light_mode : imageCapture.FillLightMode.AUTO, |
27 red_eye_reduction : true, | 28 red_eye_reduction : true, |
28 color_temperature : | 29 color_temperature : |
29 { min : 2500.0, max : 6500.0, current : 6000.0, step : 1000.0 }, | 30 { 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 }, | 31 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 }, | 32 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 }, | 33 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 }, | 34 sharpness : { min : 4.0, max : 7.0, current : 7.0, step : 1.0 }, |
34 }}; | 35 }}; |
35 this.settings_ = null; | 36 this.settings_ = null; |
36 this.bindingSet_ = new bindings.BindingSet(imageCapture.ImageCapture); | 37 } |
| 38 |
| 39 bindToPipe(pipe) { |
| 40 this.stub_ = connection.bindHandleToStub(pipe, imageCapture.ImageCapture); |
| 41 bindings.StubBindings(this.stub_).delegate = this; |
37 } | 42 } |
38 | 43 |
39 getCapabilities(source_id) { | 44 getCapabilities(source_id) { |
40 return Promise.resolve(this.capabilities_); | 45 return Promise.resolve(this.capabilities_); |
41 } | 46 } |
42 | 47 |
43 setOptions(source_id, settings) { | 48 setOptions(source_id, settings) { |
44 this.settings_ = settings; | 49 this.settings_ = settings; |
45 return Promise.resolve({ success : true }); | 50 return Promise.resolve({ success : true }); |
46 } | 51 } |
47 | 52 |
48 takePhoto(source_id) { | 53 takePhoto(source_id) { |
49 return Promise.resolve({ blob : { mime_type : 'image/cat', | 54 return Promise.resolve({ blob : { mime_type : 'image/cat', |
50 data : new Array(2) } }); | 55 data : new Array(2) } }); |
51 } | 56 } |
52 | 57 |
53 capabilities() { | 58 capabilities() { |
54 return this.capabilities_.capabilities; | 59 return this.capabilities_.capabilities; |
55 } | 60 } |
56 | 61 |
57 options() { | 62 options() { |
58 return this.settings_; | 63 return this.settings_; |
59 } | 64 } |
60 | 65 |
61 } | 66 } |
62 return new MockImageCapture(); | 67 return new MockImageCapture(); |
63 }); | 68 }); |
OLD | NEW |