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

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

Powered by Google App Engine
This is Rietveld 408576698