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