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

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.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 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 unified diff | Download patch
OLDNEW
1 "use strict"; 1 "use strict";
2 2
3 let mockShapeDetectionReady = define( 3 let mockFaceDetectionReady = define(
4 'mockShapeDetection', 4 'mockFaceDetection',
5 ['third_party/WebKit/public/platform/modules/shapedetection/shapedetection.moj om', 5 ['third_party/WebKit/public/platform/modules/shapedetection/facedetection.mojo m',
6 'mojo/public/js/bindings', 6 'mojo/public/js/bindings',
7 'mojo/public/js/connection', 7 'mojo/public/js/connection',
8 'mojo/public/js/core', 8 'mojo/public/js/core',
9 'content/public/renderer/frame_interfaces', 9 'content/public/renderer/frame_interfaces',
10 ], (shapeDetection, bindings, connection, mojo, interfaces) => { 10 ], (faceDetection, bindings, connection, mojo, interfaces) => {
11 11
12 class MockShapeDetection { 12 class MockFaceDetection {
13 constructor() { 13 constructor() {
14 interfaces.addInterfaceOverrideForTesting( 14 interfaces.addInterfaceOverrideForTesting(
15 shapeDetection.ShapeDetection.name, 15 faceDetection.FaceDetection.name,
16 pipe => this.bindToPipe(pipe)); 16 pipe => this.bindToPipe(pipe));
17 } 17 }
18 18
19 bindToPipe(pipe) { 19 bindToPipe(pipe) {
20 this.stub_ = connection.bindHandleToStub(pipe, 20 this.stub_ = connection.bindHandleToStub(pipe,
21 shapeDetection.ShapeDetection); 21 faceDetection.FaceDetection);
22 bindings.StubBindings(this.stub_).delegate = this; 22 bindings.StubBindings(this.stub_).delegate = this;
23 } 23 }
24 24
25 detectFaces(frame_data, width, height, options) { 25 detect(frame_data, width, height, options) {
26 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); 26 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
27 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); 27 this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
28 this.maxDetectedFaces_ = options.max_detected_faces; 28 this.maxDetectedFaces_ = options.max_detected_faces;
29 this.fastMode_ = options.fast_mode; 29 this.fastMode_ = options.fast_mode;
30 return Promise.resolve({ 30 return Promise.resolve({
31 result: { 31 result: {
32 bounding_boxes: [ 32 bounding_boxes: [
33 { x : 1.0, y: 1.0, width: 100.0, height: 100.0 }, 33 { x : 1.0, y: 1.0, width: 100.0, height: 100.0 },
34 { x : 2.0, y: 2.0, width: 200.0, height: 200.0 }, 34 { x : 2.0, y: 2.0, width: 200.0, height: 200.0 },
35 { x : 3.0, y: 3.0, width: 300.0, height: 300.0 }, 35 { x : 3.0, y: 3.0, width: 300.0, height: 300.0 },
36 ] 36 ]
37 } 37 }
38 }); 38 });
39 mojo.unmapBuffer(receivedStruct.buffer); 39 mojo.unmapBuffer(receivedStruct.buffer);
40 } 40 }
41 41
42 detectBarcodes(frame_data, width, height) {
43 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
44 this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
45 return Promise.resolve({
46 results: [
47 {
48 raw_value : "cats",
49 bounding_box: { x : 1.0, y: 1.0, width: 100.0, height: 100.0 },
50 },
51 {
52 raw_value : "dogs",
53 bounding_box: { x : 2.0, y: 2.0, width: 50.0, height: 50.0 },
54 },
55 ],
56 });
57 mojo.unmapBuffer(receivedStruct.buffer);
58 }
59
60 getFrameData() { 42 getFrameData() {
61 return this.buffer_data_; 43 return this.buffer_data_;
62 } 44 }
63 45
64 getMaxDetectedFaces() { 46 getMaxDetectedFaces() {
65 return this.maxDetectedFaces_; 47 return this.maxDetectedFaces_;
66 } 48 }
67 49
68 getFastMode () { 50 getFastMode () {
69 return this.fastMode_; 51 return this.fastMode_;
70 } 52 }
71 } 53 }
72 return new MockShapeDetection(); 54 return new MockFaceDetection();
73 }); 55 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698