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

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

Issue 2553343003: ShapeDetection: add support for all CanvasImageSource input types (Closed)
Patch Set: reillyg@s comments 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script src="resources/mock-barcodedetection.js"></script> 5 <script src="resources/mock-barcodedetection.js"></script>
6 <script src="resources/mock-facedetection.js"></script> 6 <script src="resources/mock-facedetection.js"></script>
7 <body> 7 <body>
8 <img id='img' src='../media/content/greenbox.png'/> 8 <img id="img" src="../media/content/greenbox.png"/>
9 </body> 9 </body>
10 <script> 10 <script>
11 11
12 var createTestForImageElement = function(detectorName, mockReady, 12 var createTestForImageElement = function(createDetector, mockReady,
13 detectionResultTest) { 13 detectionResultTest) {
14 async_test(function(t) { 14 async_test(function(t) {
15 var img = document.getElementById("img"); 15 var img = document.getElementById("img");
16 16
17 var theMock = null; 17 var theMock = null;
18 mockReady() 18 mockReady()
19 .then(mock => { 19 .then(mock => {
20 theMock = mock; 20 theMock = mock;
21 var detector = eval("new " + detectorName + "();"); 21 var detector = createDetector();
22 return detector; 22 return detector;
23 }) 23 })
24 .catch(error => { 24 .catch(error => {
25 assert_unreached("Error creating MockFaceDetection: " + error); 25 assert_unreached("Error creating Mock Detector: " + error);
26 }) 26 })
27 .then(detector => { 27 .then(detector => {
28 return detector.detect(img); 28 return detector.detect(img);
29 }) 29 })
30 .then(detectionResult => { 30 .then(detectionResult => {
31 detectionResultTest(detectionResult, theMock); 31 detectionResultTest(detectionResult, theMock);
32 t.done(); 32 t.done();
33 }) 33 })
34 .catch(error => { 34 .catch(error => {
35 assert_unreached("Error during detect(img): " + error); 35 assert_unreached("Error during detect(img): " + error);
(...skipping 14 matching lines...) Expand all
50 assert_equals(detectionResult.length, 2, "Number of barcodes"); 50 assert_equals(detectionResult.length, 2, "Number of barcodes");
51 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); 51 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1");
52 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); 52 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2");
53 } 53 }
54 54
55 // These tests verify that a Detector's detect() works on an HTMLImageElement. 55 // These tests verify that a Detector's detect() works on an HTMLImageElement.
56 // Use the mock mojo server implemented in mock-{barcode,face}detection.js. 56 // Use the mock mojo server implemented in mock-{barcode,face}detection.js.
57 generate_tests(createTestForImageElement, [ 57 generate_tests(createTestForImageElement, [
58 [ 58 [
59 "Face", 59 "Face",
60 "FaceDetector", 60 () => { return new FaceDetector(); },
61 () => { return mockFaceDetectionReady; }, 61 () => { return mockFaceDetectionReady; },
62 FaceDetectorDetectionResultTest 62 FaceDetectorDetectionResultTest
63 ], 63 ],
64 [ 64 [
65 "Barcode", 65 "Barcode",
66 "BarcodeDetector", 66 () => { return new BarcodeDetector(); },
67 () => { return mockBarcodeDetectionReady; }, 67 () => { return mockBarcodeDetectionReady; },
68 BarcodeDetectorDetectionResultTest 68 BarcodeDetectorDetectionResultTest
69 ] 69 ]
70 ]); 70 ]);
71 71
72 </script> 72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698