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