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

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/detection-ImageData.html

Issue 2550413005: ShapeDetection: use ImageBitmapSource as input and support ImageData (Closed)
Patch Set: xianglu@ comments and added forgotten LayoutTest detection-ImageData.html 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/mock-barcodedetection.js"></script>
6 <script src="resources/mock-facedetection.js"></script>
7 <script>
8
9 var createTestForImageData = function(createDetector, mockReady,
10 detectionResultTest) {
11 async_test(function(t) {
12
13 var img = new Image();
14 img.onload = function() {
15
16 var canvas = document.createElement("canvas");;
17 canvas.getContext("2d").drawImage(img, 0, 0);
18
19 var theMock = null;
20 mockReady()
21 .then(mock => {
22 theMock = mock;
23 var detector = createDetector();
24 return detector;
25 })
26 .catch(error => {
27 assert_unreached("Error creating Mock Detector: " + error);
28 })
29 .then(detector => {
30 return detector.detect(canvas.getContext("2d").getImageData(
31 0, 0, canvas.width, canvas.height));
32 })
33 .then(detectionResult => {
34 detectionResultTest(detectionResult, theMock);
35 t.done();
36 })
37 .catch(error => {
38 assert_unreached("Error during detect(canvas): " + error);
39 });
40 }
41
42 img.src = "../media/content/greenbox.png";
43 }, "Detector detect(ImageData)");
44 };
45
46 function FaceDetectorDetectionResultTest(detectionResult, mock) {
47 const imageReceivedByMock = mock.getFrameData();
48 assert_equals(imageReceivedByMock.byteLength, 180000,"Image length");
49 const GREEN_PIXEL = 0xFF00FF00;
50 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color");
51 assert_equals(detectionResult.length, 3, "Number of faces");
52 }
53
54 function BarcodeDetectorDetectionResultTest(detectionResult, mock) {
55 assert_equals(detectionResult.length, 2, "Number of barcodes");
56 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1");
57 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2");
58 }
59
60 // These tests verify that a Detector's detect() works on an ImageBitmap. Use
61 // the mock mojo server implemented in mock-{barcode,face}detection.js.
62 generate_tests(createTestForImageData, [
63 [
64 "Face - ImageData",
65 () => { return new FaceDetector(); },
66 () => { return mockFaceDetectionProviderReady; },
67 FaceDetectorDetectionResultTest
68 ],
69 [
70 "Barcode - ImageData",
71 () => { return new BarcodeDetector(); },
72 () => { return mockBarcodeDetectionReady; },
73 BarcodeDetectorDetectionResultTest
74 ],
75 ]);
76
77 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/shapedetection/BarcodeDetector.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698