| Index: third_party/WebKit/LayoutTests/shapedetection/resources/mock-textdetection.js
|
| diff --git a/third_party/WebKit/LayoutTests/shapedetection/resources/mock-textdetection.js b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-textdetection.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..06bc8118758cf8ee0f36d34ffef3b573ac0c90ee
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-textdetection.js
|
| @@ -0,0 +1,43 @@
|
| +"use strict";
|
| +
|
| +let mockTextDetectionReady = define(
|
| + 'mockTextDetection',
|
| + ['third_party/WebKit/public/platform/modules/shapedetection/textdetection.mojom',
|
| + 'mojo/public/js/bindings',
|
| + 'mojo/public/js/core',
|
| + 'content/public/renderer/frame_interfaces',
|
| + ], (textDetection, bindings, mojo, interfaces) => {
|
| +
|
| + class MockTextDetection {
|
| + constructor() {
|
| + this.bindingSet_ = new bindings.BindingSet(textDetection.TextDetection);
|
| +
|
| + interfaces.addInterfaceOverrideForTesting(
|
| + textDetection.TextDetection.name,
|
| + handle => this.bindingSet_.addBinding(this, handle));
|
| + }
|
| +
|
| + detect(frame_data, width, height) {
|
| + let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
|
| + this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
|
| + return Promise.resolve({
|
| + results: [
|
| + {
|
| + raw_value : "cats",
|
| + bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 }
|
| + },
|
| + {
|
| + raw_value : "dogs",
|
| + bounding_box: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 }
|
| + },
|
| + ],
|
| + });
|
| + mojo.unmapBuffer(receivedStruct.buffer);
|
| + }
|
| +
|
| + getFrameData() {
|
| + return this.buffer_data_;
|
| + }
|
| + }
|
| + return new MockTextDetection();
|
| +});
|
|
|