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

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

Issue 2522143002: ShapeDetection: split mojom into face and barcode interfaces (Closed)
Patch Set: Smart rebase to https://crrev.com/2527503003 (FaceDetectorOptions) Created 4 years, 1 month 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-barcodedetection.js
diff --git a/third_party/WebKit/LayoutTests/shapedetection/resources/mock-barcodedetection.js b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-barcodedetection.js
new file mode 100644
index 0000000000000000000000000000000000000000..bcf191dda27c2e2c8915e6d2e32bf941bfe0c346
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-barcodedetection.js
@@ -0,0 +1,48 @@
+"use strict";
+
+let mockBarcodeDetectionReady = define(
+ 'mockBarcodeDetection',
+ ['third_party/WebKit/public/platform/modules/shapedetection/barcodedetection.mojom',
+ 'mojo/public/js/bindings',
+ 'mojo/public/js/connection',
+ 'mojo/public/js/core',
+ 'content/public/renderer/frame_interfaces',
+ ], (barcodeDetection, bindings, connection, mojo, interfaces) => {
+
+ class MockBarcodeDetection {
+ constructor() {
+ interfaces.addInterfaceOverrideForTesting(
+ barcodeDetection.BarcodeDetection.name,
+ pipe => this.bindToPipe(pipe));
+ }
+
+ bindToPipe(pipe) {
+ this.stub_ = connection.bindHandleToStub(pipe,
+ barcodeDetection.BarcodeDetection);
+ bindings.StubBindings(this.stub_).delegate = this;
+ }
+
+ 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 MockBarcodeDetection();
+});

Powered by Google App Engine
This is Rietveld 408576698