| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 | 2 |
| 3 let mockBarcodeDetectionReady = define( | 3 let mockBarcodeDetectionReady = define( |
| 4 'mockBarcodeDetection', | 4 'mockBarcodeDetection', |
| 5 ['services/shape_detection/public/interfaces/barcodedetection.mojom', | 5 ['services/shape_detection/public/interfaces/barcodedetection.mojom', |
| 6 'mojo/public/js/bindings', | 6 'mojo/public/js/bindings', |
| 7 'mojo/public/js/core', | 7 'mojo/public/js/core', |
| 8 'content/public/renderer/interfaces', | 8 'content/public/renderer/interfaces', |
| 9 ], (barcodeDetection, bindings, mojo, interfaces) => { | 9 ], (barcodeDetection, bindings, mojo, interfaces) => { |
| 10 | 10 |
| 11 class MockBarcodeDetection { | 11 class MockBarcodeDetection { |
| 12 constructor() { | 12 constructor() { |
| 13 this.bindingSet_ = new bindings.BindingSet( | 13 this.bindingSet_ = new bindings.BindingSet( |
| 14 barcodeDetection.BarcodeDetection); | 14 barcodeDetection.BarcodeDetection); |
| 15 | 15 |
| 16 interfaces.addInterfaceOverrideForTesting( | 16 interfaces.addInterfaceOverrideForTesting( |
| 17 barcodeDetection.BarcodeDetection.name, | 17 barcodeDetection.BarcodeDetection.name, |
| 18 handle => this.bindingSet_.addBinding(this, handle)); | 18 handle => this.bindingSet_.addBinding(this, handle)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 detect(bitmap_data) { | 21 detect(frame_data, width, height) { |
| 22 let receivedStruct = new Uint8Array(bitmap_data.pixel_data); | 22 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); |
| 23 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); | 23 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); |
| 24 return Promise.resolve({ | 24 return Promise.resolve({ |
| 25 results: [ | 25 results: [ |
| 26 { | 26 { |
| 27 raw_value : "cats", | 27 raw_value : "cats", |
| 28 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 }, | 28 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 }, |
| 29 corner_points: [ | 29 corner_points: [ |
| 30 { x: 1.0, y: 1.0 }, | 30 { x: 1.0, y: 1.0 }, |
| 31 { x: 101.0, y: 1.0 }, | 31 { x: 101.0, y: 1.0 }, |
| 32 { x: 101.0, y: 101.0 }, | 32 { x: 101.0, y: 101.0 }, |
| 33 { x: 1.0, y: 101.0 } | 33 { x: 1.0, y: 101.0 } |
| 34 ], | 34 ], |
| 35 }, | 35 }, |
| 36 { | 36 { |
| 37 raw_value : "dogs", | 37 raw_value : "dogs", |
| 38 bounding_box: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 }, | 38 bounding_box: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 }, |
| 39 corner_points: [ | 39 corner_points: [ |
| 40 { x: 2.0, y: 2.0 }, | 40 { x: 2.0, y: 2.0 }, |
| 41 { x: 52.0, y: 2.0 }, | 41 { x: 52.0, y: 2.0 }, |
| 42 { x: 52.0, y: 52.0 }, | 42 { x: 52.0, y: 52.0 }, |
| 43 { x: 2.0, y: 52.0 } | 43 { x: 2.0, y: 52.0 } |
| 44 ], | 44 ], |
| 45 }, | 45 }, |
| 46 ], | 46 ], |
| 47 }); | 47 }); |
| 48 mojo.unmapBuffer(receivedStruct.buffer); |
| 48 } | 49 } |
| 49 | 50 |
| 50 getFrameData() { | 51 getFrameData() { |
| 51 return this.buffer_data_; | 52 return this.buffer_data_; |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 return new MockBarcodeDetection(); | 55 return new MockBarcodeDetection(); |
| 55 }); | 56 }); |
| OLD | NEW |