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

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

Issue 2564163003: ShapeDetection: Add ShapeDetectionProvider (Closed)
Patch Set: Fix layout tests, rebase Created 4 years 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-facedetection.js
diff --git a/third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.js b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.js
index 3efddb27edb3f87ab2ff16846f275a91d7684a61..7ef7d1c1ad9e571d24ab463ec6f8be3c62e7aef3 100644
--- a/third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.js
+++ b/third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.js
@@ -1,32 +1,64 @@
"use strict";
let mockFaceDetectionReady = define(
mcasas 2016/12/13 17:37:32 s/mockFaceDetectionReady/mockFaceDetectionProvider
xianglu 2016/12/13 19:17:28 Done.
- 'mockFaceDetection',
+ 'mockFaceDetectionProvider',
['third_party/WebKit/public/platform/modules/shapedetection/facedetection.mojom',
+ 'third_party/WebKit/public/platform/modules/shapedetection/facedetection_provider.mojom',
'mojo/public/js/bindings',
'mojo/public/js/connection',
'mojo/public/js/core',
'content/public/renderer/frame_interfaces',
- ], (faceDetection, bindings, connection, mojo, interfaces) => {
+ ], (faceDetection, faceDetectionProvider, bindings, connection, mojo, interfaces) => {
- class MockFaceDetection {
+ class MockFaceDetectionProvider {
constructor() {
interfaces.addInterfaceOverrideForTesting(
+ faceDetectionProvider.FaceDetectionProvider.name,
+ pipe => this.bindToPipe(pipe));
+ }
+
+ bindToPipe(pipe) {
+ this.stub_ = connection.bindHandleToStub(
+ pipe, faceDetectionProvider.FaceDetectionProvider);
+ bindings.StubBindings(this.stub_).delegate = this;
+ }
+
+ createFaceDetection(stub, options) {
+ this.mock_service_ = new MockFaceDetection(options);
+ bindings.StubBindings(stub).delegate = this.mock_service_;
+ }
+
+ getFrameData() {
+ return this.mock_service_.buffer_data_;
+ }
+
+ getMaxDetectedFaces() {
+ return this.mock_service_.maxDetectedFaces_;
+ }
+
+ getFastMode () {
+ return this.mock_service_.fastMode_;
+ }
+ }
+
+ class MockFaceDetection {
+ constructor(options) {
+ interfaces.addInterfaceOverrideForTesting(
faceDetection.FaceDetection.name,
pipe => this.bindToPipe(pipe));
+ this.maxDetectedFaces_ = options.max_detected_faces;
+ this.fastMode_ = options.fast_mode;
}
bindToPipe(pipe) {
- this.stub_ = connection.bindHandleToStub(pipe,
- faceDetection.FaceDetection);
+ this.stub_ = connection.bindHandleToStub(
+ pipe, faceDetection.FaceDetection);
bindings.StubBindings(this.stub_).delegate = this;
}
- detect(frame_data, width, height, options) {
+ detect(frame_data, width, height) {
let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
- this.maxDetectedFaces_ = options.max_detected_faces;
- this.fastMode_ = options.fast_mode;
return Promise.resolve({
result: {
bounding_boxes: [
@@ -38,18 +70,6 @@ let mockFaceDetectionReady = define(
});
mojo.unmapBuffer(receivedStruct.buffer);
}
-
- getFrameData() {
- return this.buffer_data_;
- }
-
- getMaxDetectedFaces() {
- return this.maxDetectedFaces_;
- }
-
- getFastMode () {
- return this.fastMode_;
- }
}
- return new MockFaceDetection();
+ return new MockFaceDetectionProvider();
});

Powered by Google App Engine
This is Rietveld 408576698