Chromium Code Reviews| 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 detectFace(frame_data, width, height) { | |
| 26 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); | |
| 27 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); | |
| 28 return Promise.resolve({ | |
| 29 result: { | |
| 30 boundingBoxes: [ | |
| 31 { x : 0.0, y: 0.0, width: 1.0, height: 1.0 }, | |
| 32 { x : 0.0, y: 0.0, width: 0.8, height: 0.8 }, | |
| 33 { x : 0.0, y: 0.0, width: 0.8, height: 0.5 }, | |
|
esprehn
2016/10/04 01:01:44
can we get some tests outside the [0, 1] range? Yo
| |
| 34 ] | |
| 35 } | |
| 36 }); | |
| 37 mojo.unmapBuffer(receivedStruct.buffer); | |
| 38 } | |
| 39 | |
| 40 getFrameData() { | |
| 41 return this.buffer_data_; | |
| 42 } | |
| 43 } | |
| 44 return new MockShapeDetection(); | |
| 45 }); | |
| OLD | NEW |