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

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

Issue 2369693002: Shapedetection module: Blink side implementation (Closed)
Patch Set: Naming and const correctness suggestions by mcasas@ Created 4 years, 3 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-shapedetection.js
diff --git a/third_party/WebKit/LayoutTests/shapedetection/resources/mock-shapedetection.js b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-shapedetection.js
new file mode 100644
index 0000000000000000000000000000000000000000..e522ae17b301cd58c4be6df522c6314ef42a6b2c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-shapedetection.js
@@ -0,0 +1,43 @@
+"use strict";
+
+let mockShapeDetectionReady = define(
+ 'mockShapeDetection',
+ ['third_party/WebKit/public/platform/modules/shapedetection/shapedetection.mojom',
+ 'mojo/public/js/bindings',
+ 'mojo/public/js/connection',
+ 'mojo/public/js/core',
+ 'content/public/renderer/frame_interfaces',
+ ], (shapeDetection, bindings, connection, mojo, interfaces) => {
+
+ class MockShapeDetection {
+ constructor() {
+ interfaces.addInterfaceOverrideForTesting(
+ shapeDetection.ShapeDetection.name,
+ pipe => this.bindToPipe(pipe));
+ }
+
+ bindToPipe(pipe) {
+ this.stub_ = connection.bindHandleToStub(pipe, shapeDetection.ShapeDetection);
+ bindings.StubBindings(this.stub_).delegate = this;
+ }
+
+ detectFace(frame_data, width, height) {
+ let mojoResult = mojo.mapBuffer(frame_data, 0 /*offset*/, width*height*4/*size*/, 0/*flag*/);
Ken Rockot(use gerrit already) 2016/09/30 18:05:23 nit: the inline comments are probably unnecessary
xianglu 2016/10/03 18:12:07 Done.
+ this.buffer_data_ = new Uint32Array(mojoResult.buffer);
+ return Promise.resolve(
+ { boundingBoxes :
Ken Rockot(use gerrit already) 2016/09/30 18:05:23 style nit: I don't think this is correct indenting
xianglu 2016/10/03 18:12:07 Done.
+ [
+ { x : 1.0, y: 1.0, width: 100.0, height: 100.0 },
+ { x : 2.0, y: 2.0, width: 200.0, height: 200.0 },
+ { x : 3.0, y: 3.0, width: 300.0, height: 300.0 },
+ ]
+ });
+ mojo.unmapBuffer(mojoResult.buffer);
+ }
+
+ getFrameData() {
+ return this.buffer_data_;
+ }
+ }
+ return new MockShapeDetection();
+});

Powered by Google App Engine
This is Rietveld 408576698