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

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

Issue 2522143002: ShapeDetection: split mojom into face and barcode interfaces (Closed)
Patch Set: Smart rebase to https://crrev.com/2527503003 (FaceDetectorOptions) 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-shapedetection.js"></script> 5 <script src="resources/mock-barcodedetection.js"></script>
6 <script src="resources/mock-facedetection.js"></script>
6 <body> 7 <body>
7 <img id='img' src='../media/content/greenbox.png'/> 8 <img id='img' src='../media/content/greenbox.png'/>
8 </body> 9 </body>
9 <script> 10 <script>
10 11
11 var createTestForImageElement = function(detectorName, detectionResultTest) { 12 var createTestForImageElement = function(detectorName, mockReady,
13 detectionResultTest) {
12 async_test(function(t) { 14 async_test(function(t) {
13 var img = document.getElementById("img"); 15 var img = document.getElementById("img");
14 16
15 var theMock = null; 17 var theMock = null;
16 mockShapeDetectionReady 18 mockReady()
17 .then(mock => { 19 .then(mock => {
18 theMock = mock; 20 theMock = mock;
19 var detector = eval("new " + detectorName + "();"); 21 var detector = eval("new " + detectorName + "();");
20 return detector; 22 return detector;
21 }) 23 })
22 .catch(error => { 24 .catch(error => {
23 assert_unreached("Error creating MockShapeDetection: " + error); 25 assert_unreached("Error creating MockFaceDetection: " + error);
24 }) 26 })
25 .then(detector => { 27 .then(detector => {
26 return detector.detect(img); 28 return detector.detect(img);
27 }) 29 })
28 .then(detectionResult => { 30 .then(detectionResult => {
29 detectionResultTest(detectionResult, theMock); 31 detectionResultTest(detectionResult, theMock);
30 t.done(); 32 t.done();
31 }) 33 })
32 .catch(error => { 34 .catch(error => {
33 assert_unreached("Error during detect(img): " + error); 35 assert_unreached("Error during detect(img): " + error);
(...skipping 10 matching lines...) Expand all
44 assert_equals(detectionResult.length, 3, "Number of faces"); 46 assert_equals(detectionResult.length, 3, "Number of faces");
45 } 47 }
46 48
47 function BarcodeDetectorDetectionResultTest(detectionResult, mock) { 49 function BarcodeDetectorDetectionResultTest(detectionResult, mock) {
48 assert_equals(detectionResult.length, 2, "Number of barcodes"); 50 assert_equals(detectionResult.length, 2, "Number of barcodes");
49 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); 51 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1");
50 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); 52 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2");
51 } 53 }
52 54
53 // 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.
54 // Use the mock mojo server implemented in mock-shapedetection.js. 56 // Use the mock mojo server implemented in mock-{barcode,face}detection.js.
55 generate_tests(createTestForImageElement, [ 57 generate_tests(createTestForImageElement, [
56 [ "Face", "FaceDetector", FaceDetectorDetectionResultTest ], 58 [
57 [ "Barcode", "BarcodeDetector", BarcodeDetectorDetectionResultTest ] 59 "Face",
60 "FaceDetector",
61 () => { return mockFaceDetectionReady; },
62 FaceDetectorDetectionResultTest
63 ],
64 [
65 "Barcode",
66 "BarcodeDetector",
67 () => { return mockBarcodeDetectionReady; },
68 BarcodeDetectorDetectionResultTest
69 ]
58 ]); 70 ]);
59 71
60 </script> 72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698