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

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

Issue 2369693002: Shapedetection module: Blink side implementation (Closed)
Patch Set: FaceDetector: remove normalization && use ScriptState in constructor Created 4 years, 2 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..27dcd68dd97b846e6447422fb6183e7685a24827
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-shapedetection.js
@@ -0,0 +1,45 @@
+"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 receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
+ this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
+ return Promise.resolve({
+ result: {
+ boundingBoxes: [
+ { x : 0.0, y: 0.0, width: 1.0, height: 1.0 },
+ { x : 0.0, y: 0.0, width: 0.8, height: 0.8 },
+ { 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
+ ]
+ }
+ });
+ mojo.unmapBuffer(receivedStruct.buffer);
+ }
+
+ getFrameData() {
+ return this.buffer_data_;
+ }
+ }
+ return new MockShapeDetection();
+});

Powered by Google App Engine
This is Rietveld 408576698