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

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

Issue 2857803002: Shape Detection: reconnect LayoutTests (Closed)
Patch Set: Removed expectation files and corrected shapedetection-empty-input test Created 3 years, 7 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 <!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 <script src="resources/mock-textdetection.js"></script> 7 <script src="resources/mock-textdetection.js"></script>
8 <body> 8 <body>
9 <img id="img" src="../media/content/greenbox.png"/> 9 <img id="img" src="../media/content/greenbox.png"/>
10 </body> 10 </body>
(...skipping 18 matching lines...) Expand all
29 return detector.detect(img); 29 return detector.detect(img);
30 }) 30 })
31 .then(detectionResult => { 31 .then(detectionResult => {
32 detectionResultTest(detectionResult, theMock); 32 detectionResultTest(detectionResult, theMock);
33 t.done(); 33 t.done();
34 }) 34 })
35 .catch(error => { 35 .catch(error => {
36 assert_unreached("Error during detect(img): " + error); 36 assert_unreached("Error during detect(img): " + error);
37 }); 37 });
38 38
39 }, "Detector detect(HTMLImageElement)"); 39 });
40 }; 40 };
41 41
42 function FaceDetectorDetectionResultTest(detectionResult, mock) { 42 function FaceDetectorDetectionResultTest(detectionResult, mock) {
43 const imageReceivedByMock = mock.getFrameData(); 43 const imageReceivedByMock = mock.getFrameData();
44 assert_equals(imageReceivedByMock.byteLength, 2500, "Image length"); 44 assert_equals(imageReceivedByMock.byteLength, 2500, "Image length");
45 const GREEN_PIXEL = 0xFF00FF00; 45 const GREEN_PIXEL = 0xFF00FF00;
46 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color"); 46 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color");
47 assert_equals(detectionResult.length, 3, "Number of faces"); 47 assert_equals(detectionResult.length, 3, "Number of faces");
48 } 48 }
49 49
50 function BarcodeDetectorDetectionResultTest(detectionResult, mock) { 50 function BarcodeDetectorDetectionResultTest(detectionResult, mock) {
51 assert_equals(detectionResult.length, 2, "Number of barcodes"); 51 assert_equals(detectionResult.length, 2, "Number of barcodes");
52 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); 52 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1");
53 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); 53 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2");
54 } 54 }
55 55
56 function TextDetectorDetectionResultTest(detectionResult, mock) { 56 function TextDetectorDetectionResultTest(detectionResult, mock) {
57 assert_equals(detectionResult.length, 2, "Number of textBlocks"); 57 assert_equals(detectionResult.length, 2, "Number of textBlocks");
58 assert_equals(detectionResult[0].rawValue, "cats", "textBlock 1"); 58 assert_equals(detectionResult[0].rawValue, "cats", "textBlock 1");
59 assert_equals(detectionResult[1].rawValue, "dogs", "textBlock 2"); 59 assert_equals(detectionResult[1].rawValue, "dogs", "textBlock 2");
60 } 60 }
61 61
62 // These tests verify that a Detector's detect() works on an HTMLImageElement. 62 // These tests verify that a Detector's detect() works on an HTMLImageElement.
63 // Use the mock mojo server implemented in mock-{barcode,face}detection.js. 63 // Use the mock mojo server implemented in mock-{barcode,face}detection.js.
64 generate_tests(createTestForImageElement, [ 64 generate_tests(createTestForImageElement, [
65 [ 65 [
66 "Face", 66 "Face - detect(HTMLImageElement)",
67 () => { return new FaceDetector(); }, 67 () => { return new FaceDetector(); },
68 () => { return mockFaceDetectionProviderReady; }, 68 () => { return mockFaceDetectionProviderReady; },
69 FaceDetectorDetectionResultTest 69 FaceDetectorDetectionResultTest
70 ], 70 ],
71 [ 71 [
72 "Barcode", 72 "Barcode - detect(HTMLImageElement)",
73 () => { return new BarcodeDetector(); }, 73 () => { return new BarcodeDetector(); },
74 () => { return mockBarcodeDetectionReady; }, 74 () => { return mockBarcodeDetectionReady; },
75 BarcodeDetectorDetectionResultTest 75 BarcodeDetectorDetectionResultTest
76 ], 76 ],
77 [ 77 [
78 "Text", 78 "Text - detect(HTMLImageElement)",
79 () => { return new TextDetector(); }, 79 () => { return new TextDetector(); },
80 () => { return mockTextDetectionReady; }, 80 () => { return mockTextDetectionReady; },
81 TextDetectorDetectionResultTest 81 TextDetectorDetectionResultTest
82 ] 82 ]
83 ]); 83 ]);
84 84
85 </script> 85 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698