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

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

Issue 2818563006: ShapeDetection: Holding all of mock service to prevent GC (Closed)
Patch Set: ShapeDetection: Make sure tests are running serially Created 3 years, 6 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
« no previous file with comments | « third_party/WebKit/LayoutTests/shapedetection/detection-HTMLCanvasElement.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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', 8 'mojo/public/js/core',
9 'content/public/renderer/interfaces', 9 'content/public/renderer/interfaces',
10 ], (faceDetection, faceDetectionProvider, bindings, mojo, interfaces) => { 10 ], (faceDetection, faceDetectionProvider, bindings, mojo, interfaces) => {
11 11
12 class MockFaceDetectionProvider { 12 class MockFaceDetectionProvider {
13 constructor() { 13 constructor() {
14 this.bindingSet_ = new bindings.BindingSet( 14 this.bindingSet_ = new bindings.BindingSet(
15 faceDetectionProvider.FaceDetectionProvider); 15 faceDetectionProvider.FaceDetectionProvider);
16 16
17 interfaces.addInterfaceOverrideForTesting( 17 interfaces.addInterfaceOverrideForTesting(
18 faceDetectionProvider.FaceDetectionProvider.name, 18 faceDetectionProvider.FaceDetectionProvider.name,
19 handle => this.bindingSet_.addBinding(this, handle)); 19 handle => this.bindingSet_.addBinding(this, handle));
20 } 20 }
21 21
22 createFaceDetection(request, options) { 22 createFaceDetection(request, options) {
23 this.mock_service_ = new MockFaceDetection(request, options); 23 this.mockService_ = new MockFaceDetection(request, options);
24 } 24 }
25 25
26 getFrameData() { 26 getFrameData() {
27 return this.mock_service_.buffer_data_; 27 return this.mockService_.bufferData_;
28 } 28 }
29 29
30 getMaxDetectedFaces() { 30 getMaxDetectedFaces() {
31 return this.mock_service_.maxDetectedFaces_; 31 return this.mockService_.maxDetectedFaces_;
32 } 32 }
33 33
34 getFastMode () { 34 getFastMode () {
35 return this.mock_service_.fastMode_; 35 return this.mockService_.fastMode_;
36 } 36 }
37 } 37 }
38 38
39 class MockFaceDetection { 39 class MockFaceDetection {
40 constructor(request, options) { 40 constructor(request, options) {
41 this.maxDetectedFaces_ = options.max_detected_faces; 41 this.maxDetectedFaces_ = options.max_detected_faces;
42 this.fastMode_ = options.fast_mode; 42 this.fastMode_ = options.fast_mode;
43 this.binding_ = new bindings.Binding(faceDetection.FaceDetection, this, 43 this.binding_ = new bindings.Binding(faceDetection.FaceDetection, this,
44 request); 44 request);
45 } 45 }
46 46
47 detect(frame_data, width, height) { 47 detect(frame_data, width, height) {
48 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); 48 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0);
49 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); 49 this.bufferData_ = new Uint32Array(receivedStruct.buffer);
50 return Promise.resolve({ 50 return Promise.resolve({
51 results: [ 51 results: [
52 { 52 {
53 bounding_box: {x: 1.0, y: 1.0, width: 100.0, height: 100.0}, 53 bounding_box: {x: 1.0, y: 1.0, width: 100.0, height: 100.0},
54 landmarks: [{ 54 landmarks: [{
55 type: faceDetection.LandmarkType.EYE, 55 type: faceDetection.LandmarkType.EYE,
56 location: {x: 4.0, y: 5.0} 56 location: {x: 4.0, y: 5.0}
57 }] 57 }]
58 }, 58 },
59 { 59 {
60 bounding_box: {x: 2.0, y: 2.0, width: 200.0, height: 200.0}, 60 bounding_box: {x: 2.0, y: 2.0, width: 200.0, height: 200.0},
61 landmarks: [] 61 landmarks: []
62 }, 62 },
63 { 63 {
64 bounding_box: {x: 3.0, y: 3.0, width: 300.0, height: 300.0}, 64 bounding_box: {x: 3.0, y: 3.0, width: 300.0, height: 300.0},
65 landmarks: [] 65 landmarks: []
66 }, 66 },
67 ] 67 ]
68 }); 68 });
69 mojo.unmapBuffer(receivedStruct.buffer); 69 mojo.unmapBuffer(receivedStruct.buffer);
70 } 70 }
71 } 71 }
72 return new MockFaceDetectionProvider(); 72 return new MockFaceDetectionProvider();
73 }); 73 });
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/shapedetection/detection-HTMLCanvasElement.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698