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

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/detection-ImageData.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 <script> 8 <script>
9 9
10 var createTestForImageData = function(createDetector, mockReady, 10 var createTestForImageData = function(createDetector, mockReady,
(...skipping 23 matching lines...) Expand all
34 .then(detectionResult => { 34 .then(detectionResult => {
35 detectionResultTest(detectionResult, theMock); 35 detectionResultTest(detectionResult, theMock);
36 t.done(); 36 t.done();
37 }) 37 })
38 .catch(error => { 38 .catch(error => {
39 assert_unreached("Error during detect(canvas): " + error); 39 assert_unreached("Error during detect(canvas): " + error);
40 }); 40 });
41 } 41 }
42 42
43 img.src = "../media/content/greenbox.png"; 43 img.src = "../media/content/greenbox.png";
44 }, "Detector detect(ImageData)"); 44 });
45 }; 45 };
46 46
47 function FaceDetectorDetectionResultTest(detectionResult, mock) { 47 function FaceDetectorDetectionResultTest(detectionResult, mock) {
48 const imageReceivedByMock = mock.getFrameData(); 48 const imageReceivedByMock = mock.getFrameData();
49 assert_equals(imageReceivedByMock.byteLength, 180000,"Image length"); 49 assert_equals(imageReceivedByMock.byteLength, 180000,"Image length");
50 const GREEN_PIXEL = 0xFF00FF00; 50 const GREEN_PIXEL = 0xFF00FF00;
51 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color"); 51 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color");
52 assert_equals(detectionResult.length, 3, "Number of faces"); 52 assert_equals(detectionResult.length, 3, "Number of faces");
53 } 53 }
54 54
55 function BarcodeDetectorDetectionResultTest(detectionResult, mock) { 55 function BarcodeDetectorDetectionResultTest(detectionResult, mock) {
56 assert_equals(detectionResult.length, 2, "Number of barcodes"); 56 assert_equals(detectionResult.length, 2, "Number of barcodes");
57 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); 57 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1");
58 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); 58 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2");
59 } 59 }
60 60
61 function TextDetectorDetectionResultTest(detectionResult, mock) { 61 function TextDetectorDetectionResultTest(detectionResult, mock) {
62 assert_equals(detectionResult.length, 2, "Number of textBlocks"); 62 assert_equals(detectionResult.length, 2, "Number of textBlocks");
63 assert_equals(detectionResult[0].rawValue, "cats", "textBlock 1"); 63 assert_equals(detectionResult[0].rawValue, "cats", "textBlock 1");
64 assert_equals(detectionResult[1].rawValue, "dogs", "textBlock 2"); 64 assert_equals(detectionResult[1].rawValue, "dogs", "textBlock 2");
65 } 65 }
66 66
67 // These tests verify that a Detector's detect() works on an ImageBitmap. Use 67 // These tests verify that a Detector's detect() works on an ImageBitmap. Use
68 // the mock mojo server implemented in mock-{barcode,face}detection.js. 68 // the mock mojo server implemented in mock-{barcode,face}detection.js.
69 generate_tests(createTestForImageData, [ 69 generate_tests(createTestForImageData, [
70 [ 70 [
71 "Face - ImageData", 71 "Face - detect(ImageData)",
72 () => { return new FaceDetector(); }, 72 () => { return new FaceDetector(); },
73 () => { return mockFaceDetectionProviderReady; }, 73 () => { return mockFaceDetectionProviderReady; },
74 FaceDetectorDetectionResultTest 74 FaceDetectorDetectionResultTest
75 ], 75 ],
76 [ 76 [
77 "Barcode - ImageData", 77 "Barcode - detect(ImageData)",
78 () => { return new BarcodeDetector(); }, 78 () => { return new BarcodeDetector(); },
79 () => { return mockBarcodeDetectionReady; }, 79 () => { return mockBarcodeDetectionReady; },
80 BarcodeDetectorDetectionResultTest 80 BarcodeDetectorDetectionResultTest
81 ], 81 ],
82 [ 82 [
83 "Text", 83 "Text - detect(ImageData)",
84 () => { return new TextDetector(); }, 84 () => { return new TextDetector(); },
85 () => { return mockTextDetectionReady; }, 85 () => { return mockTextDetectionReady; },
86 TextDetectorDetectionResultTest 86 TextDetectorDetectionResultTest
87 ] 87 ]
88 ]); 88 ]);
89 89
90 </script> 90 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698