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