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

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/resources/mock-textdetection.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 mockTextDetectionReady = define( 3 let mockTextDetectionReady = define(
4 'mockTextDetection', 4 'mockTextDetection',
5 ['services/shape_detection/public/interfaces/textdetection.mojom', 5 ['services/shape_detection/public/interfaces/textdetection.mojom',
6 'mojo/public/js/bindings', 6 'mojo/public/js/bindings',
7 'mojo/public/js/core',
8 'content/public/renderer/interfaces', 7 'content/public/renderer/interfaces',
9 ], (textDetection, bindings, mojo, interfaces) => { 8 ], (textDetection, bindings, interfaces) => {
10 9
11 class MockTextDetection { 10 class MockTextDetection {
12 constructor() { 11 constructor() {
13 this.bindingSet_ = new bindings.BindingSet(textDetection.TextDetection); 12 this.bindingSet_ = new bindings.BindingSet(textDetection.TextDetection);
14 13
15 interfaces.addInterfaceOverrideForTesting( 14 interfaces.addInterfaceOverrideForTesting(
16 textDetection.TextDetection.name, 15 textDetection.TextDetection.name,
17 handle => this.bindingSet_.addBinding(this, handle)); 16 handle => this.bindingSet_.addBinding(this, handle));
18 } 17 }
19 18
20 detect(frame_data, width, height) { 19 detect(frame_data, width, height) {
21 let receivedStruct = mojo.mapBuffer(frame_data, 0, width*height*4, 0); 20 let receivedStruct = frame_data.mapBuffer(0, width*height*4);
22 this.buffer_data_ = new Uint32Array(receivedStruct.buffer); 21 this.buffer_data_ = new Uint32Array(receivedStruct.buffer);
23 return Promise.resolve({ 22 return Promise.resolve({
24 results: [ 23 results: [
25 { 24 {
26 raw_value : "cats", 25 raw_value : "cats",
27 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 } 26 bounding_box: { x: 1.0, y: 1.0, width: 100.0, height: 100.0 }
28 }, 27 },
29 { 28 {
30 raw_value : "dogs", 29 raw_value : "dogs",
31 bounding_box: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 } 30 bounding_box: { x: 2.0, y: 2.0, width: 50.0, height: 50.0 }
32 }, 31 },
33 ], 32 ],
34 }); 33 });
35 mojo.unmapBuffer(receivedStruct.buffer);
36 } 34 }
37 35
38 getFrameData() { 36 getFrameData() {
39 return this.buffer_data_; 37 return this.buffer_data_;
40 } 38 }
41 } 39 }
42 return new MockTextDetection(); 40 return new MockTextDetection();
43 }); 41 });
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.js ('k') | third_party/WebKit/Source/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698