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

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

Issue 2405093003: [WIP] Mojo native bindings interface.
Patch Set: fixes webui tests Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 "use strict"; 1 "use strict";
2 2
3 let mockFaceDetectionProviderReady = define( 3 let mockFaceDetectionProviderReady = define(
4 'mockFaceDetectionProvider', 4 'mockFaceDetectionProvider',
5 ['services/shape_detection/public/interfaces/facedetection.mojom', 5 ['services/shape_detection/public/interfaces/facedetection.mojom',
6 'services/shape_detection/public/interfaces/facedetection_provider.mojom', 6 'services/shape_detection/public/interfaces/facedetection_provider.mojom',
7 'mojo/public/js/bindings', 7 'mojo/public/js/bindings',
8 'mojo/public/js/core',
9 'content/public/renderer/interfaces', 8 'content/public/renderer/interfaces',
10 ], (faceDetection, faceDetectionProvider, bindings, mojo, interfaces) => { 9 ], (faceDetection, faceDetectionProvider, bindings, interfaces) => {
11 10
12 class MockFaceDetectionProvider { 11 class MockFaceDetectionProvider {
13 constructor() { 12 constructor() {
14 this.bindingSet_ = new bindings.BindingSet( 13 this.bindingSet_ = new bindings.BindingSet(
15 faceDetectionProvider.FaceDetectionProvider); 14 faceDetectionProvider.FaceDetectionProvider);
16 15
17 interfaces.addInterfaceOverrideForTesting( 16 interfaces.addInterfaceOverrideForTesting(
18 faceDetectionProvider.FaceDetectionProvider.name, 17 faceDetectionProvider.FaceDetectionProvider.name,
19 handle => this.bindingSet_.addBinding(this, handle)); 18 handle => this.bindingSet_.addBinding(this, handle));
20 } 19 }
(...skipping 17 matching lines...) Expand all
38 37
39 class MockFaceDetection { 38 class MockFaceDetection {
40 constructor(request, options) { 39 constructor(request, options) {
41 this.maxDetectedFaces_ = options.max_detected_faces; 40 this.maxDetectedFaces_ = options.max_detected_faces;
42 this.fastMode_ = options.fast_mode; 41 this.fastMode_ = options.fast_mode;
43 this.binding_ = new bindings.Binding(faceDetection.FaceDetection, this, 42 this.binding_ = new bindings.Binding(faceDetection.FaceDetection, this,
44 request); 43 request);
45 } 44 }
46 45
47 detect(frame_data, width, height) { 46 detect(frame_data, width, height) {
48 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); 47 let receivedStruct = frame_data.mapBuffer(0, width*height*4);
49 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); 48 this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
50 return Promise.resolve({ 49 return Promise.resolve({
51 result: { 50 result: {
52 bounding_boxes: [ 51 bounding_boxes: [
53 { x : 1.0, y: 1.0, width: 100.0, height: 100.0 }, 52 { x : 1.0, y: 1.0, width: 100.0, height: 100.0 },
54 { x : 2.0, y: 2.0, width: 200.0, height: 200.0 }, 53 { x : 2.0, y: 2.0, width: 200.0, height: 200.0 },
55 { x : 3.0, y: 3.0, width: 300.0, height: 300.0 }, 54 { x : 3.0, y: 3.0, width: 300.0, height: 300.0 },
56 ] 55 ]
57 } 56 }
58 }); 57 });
59 mojo.unmapBuffer(receivedStruct.buffer);
60 } 58 }
61 } 59 }
62 return new MockFaceDetectionProvider(); 60 return new MockFaceDetectionProvider();
63 }); 61 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698