| OLD | NEW |
| 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> | 8 <script> |
| 8 | 9 |
| 9 var createTestForImageBitmap = function(createDetector, mockReady, | 10 var createTestForImageBitmap = function(createDetector, mockReady, |
| 10 detectionResultTest) { | 11 detectionResultTest) { |
| 11 async_test(function(t) { | 12 async_test(function(t) { |
| 12 var img = new Image(); | 13 var img = new Image(); |
| 13 | 14 |
| 14 img.onload = function() { | 15 img.onload = function() { |
| 15 var theImageBitmap = null; | 16 var theImageBitmap = null; |
| 16 var theMock = null; | 17 var theMock = null; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color"); | 54 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color"); |
| 54 assert_equals(detectionResult.length, 3, "Number of faces"); | 55 assert_equals(detectionResult.length, 3, "Number of faces"); |
| 55 } | 56 } |
| 56 | 57 |
| 57 function BarcodeDetectorDetectionResultTest(detectionResult, mock) { | 58 function BarcodeDetectorDetectionResultTest(detectionResult, mock) { |
| 58 assert_equals(detectionResult.length, 2, "Number of barcodes"); | 59 assert_equals(detectionResult.length, 2, "Number of barcodes"); |
| 59 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); | 60 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); |
| 60 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); | 61 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); |
| 61 } | 62 } |
| 62 | 63 |
| 64 function TextDetectorDetectionResultTest(detectionResult, mock) { |
| 65 assert_equals(detectionResult.length, 2, "Number of textBlocks"); |
| 66 assert_equals(detectionResult[0].rawValue, "cats", "textBlock 1"); |
| 67 assert_equals(detectionResult[1].rawValue, "dogs", "textBlock 2"); |
| 68 } |
| 69 |
| 63 // 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. |
| 64 // 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. |
| 65 generate_tests(createTestForImageBitmap, [ | 72 generate_tests(createTestForImageBitmap, [ |
| 66 [ | 73 [ |
| 67 "Face", | 74 "Face", |
| 68 () => { return new FaceDetector(); }, | 75 () => { return new FaceDetector(); }, |
| 69 () => { return mockFaceDetectionProviderReady; }, | 76 () => { return mockFaceDetectionProviderReady; }, |
| 70 FaceDetectorDetectionResultTest | 77 FaceDetectorDetectionResultTest |
| 71 ], | 78 ], |
| 72 [ | 79 [ |
| 73 "Barcode", | 80 "Barcode", |
| 74 () => { return new BarcodeDetector(); }, | 81 () => { return new BarcodeDetector(); }, |
| 75 () => { return mockBarcodeDetectionReady; }, | 82 () => { return mockBarcodeDetectionReady; }, |
| 76 BarcodeDetectorDetectionResultTest | 83 BarcodeDetectorDetectionResultTest |
| 84 ], |
| 85 [ |
| 86 "Text", |
| 87 () => { return new TextDetector(); }, |
| 88 () => { return mockTextDetectionReady; }, |
| 89 TextDetectorDetectionResultTest |
| 77 ] | 90 ] |
| 78 ]); | 91 ]); |
| 79 | 92 |
| 80 </script> | 93 </script> |
| OLD | NEW |