Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/WebKit/LayoutTests/shapedetection/resources/mock-textdetection.js

Issue 2588293005: Shape Detection: Add Text Detection in Chrome Android (Closed)
Patch Set: jochen@ comments, rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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();
+});

Powered by Google App Engine
This is Rietveld 408576698