| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 | 2 |
| 3 let mockShapeDetectionReady = define( | 3 let mockShapeDetectionReady = define( |
| 4 'mockShapeDetection', | 4 'mockShapeDetection', |
| 5 ['third_party/WebKit/public/platform/modules/shapedetection/shapedetection.moj
om', | 5 ['third_party/WebKit/public/platform/modules/shapedetection/shapedetection.moj
om', |
| 6 'mojo/public/js/bindings', | 6 'mojo/public/js/bindings', |
| 7 'mojo/public/js/connection', | 7 'mojo/public/js/connection', |
| 8 'mojo/public/js/core', | 8 'mojo/public/js/core', |
| 9 'content/public/renderer/frame_interfaces', | 9 'content/public/renderer/frame_interfaces', |
| 10 ], (shapeDetection, bindings, connection, mojo, interfaces) => { | 10 ], (shapeDetection, bindings, connection, mojo, interfaces) => { |
| 11 | 11 |
| 12 class MockShapeDetection { | 12 class MockShapeDetection { |
| 13 constructor() { | 13 constructor() { |
| 14 interfaces.addInterfaceOverrideForTesting( | 14 interfaces.addInterfaceOverrideForTesting( |
| 15 shapeDetection.ShapeDetection.name, | 15 shapeDetection.ShapeDetection.name, |
| 16 pipe => this.bindToPipe(pipe)); | 16 pipe => this.bindToPipe(pipe)); |
| 17 } | 17 } |
| 18 | 18 |
| 19 bindToPipe(pipe) { | 19 bindToPipe(pipe) { |
| 20 this.stub_ = connection.bindHandleToStub(pipe, | 20 this.stub_ = connection.bindHandleToStub(pipe, |
| 21 shapeDetection.ShapeDetection); | 21 shapeDetection.ShapeDetection); |
| 22 bindings.StubBindings(this.stub_).delegate = this; | 22 bindings.StubBindings(this.stub_).delegate = this; |
| 23 } | 23 } |
| 24 | 24 |
| 25 detectFaces(frame_data, width, height) { | 25 detectFaces(frame_data, width, height, options) { |
| 26 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); | 26 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); |
| 27 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); | 27 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); |
| 28 this.maxDetectedFaces_ = options.max_detected_faces; |
| 29 this.fastMode_ = options.fast_mode; |
| 28 return Promise.resolve({ | 30 return Promise.resolve({ |
| 29 result: { | 31 result: { |
| 30 boundingBoxes: [ | 32 bounding_boxes: [ |
| 31 { x : 1.0, y: 1.0, width: 100.0, height: 100.0 }, | 33 { x : 1.0, y: 1.0, width: 100.0, height: 100.0 }, |
| 32 { x : 2.0, y: 2.0, width: 200.0, height: 200.0 }, | 34 { x : 2.0, y: 2.0, width: 200.0, height: 200.0 }, |
| 33 { x : 3.0, y: 3.0, width: 300.0, height: 300.0 }, | 35 { x : 3.0, y: 3.0, width: 300.0, height: 300.0 }, |
| 34 ] | 36 ] |
| 35 } | 37 } |
| 36 }); | 38 }); |
| 37 mojo.unmapBuffer(receivedStruct.buffer); | 39 mojo.unmapBuffer(receivedStruct.buffer); |
| 38 } | 40 } |
| 39 | 41 |
| 40 detectBarcodes(frame_data, width, height) { | 42 detectBarcodes(frame_data, width, height) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 51 bounding_box: { x : 2.0, y: 2.0, width: 50.0, height: 50.0 }, | 53 bounding_box: { x : 2.0, y: 2.0, width: 50.0, height: 50.0 }, |
| 52 }, | 54 }, |
| 53 ], | 55 ], |
| 54 }); | 56 }); |
| 55 mojo.unmapBuffer(receivedStruct.buffer); | 57 mojo.unmapBuffer(receivedStruct.buffer); |
| 56 } | 58 } |
| 57 | 59 |
| 58 getFrameData() { | 60 getFrameData() { |
| 59 return this.buffer_data_; | 61 return this.buffer_data_; |
| 60 } | 62 } |
| 63 |
| 64 getMaxDetectedFaces() { |
| 65 return this.maxDetectedFaces_; |
| 66 } |
| 67 |
| 68 getFastMode () { |
| 69 return this.fastMode_; |
| 70 } |
| 61 } | 71 } |
| 62 return new MockShapeDetection(); | 72 return new MockShapeDetection(); |
| 63 }); | 73 }); |
| OLD | NEW |