| 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-shapedetection.js"></script> | 5 <script src="resources/mock-shapedetection.js"></script> |
| 6 <body> | 6 <body> |
| 7 <img id='img' src='../media/content/greenbox.png'/> | 7 <img id='img' src='../media/content/greenbox.png'/> |
| 8 </body> | 8 </body> |
| 9 <script> | 9 <script> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 return detector.detect(img); | 26 return detector.detect(img); |
| 27 }) | 27 }) |
| 28 .then(detectionResult => { | 28 .then(detectionResult => { |
| 29 detectionResultTest(detectionResult, theMock); | 29 detectionResultTest(detectionResult, theMock); |
| 30 t.done(); | 30 t.done(); |
| 31 }) | 31 }) |
| 32 .catch(error => { | 32 .catch(error => { |
| 33 assert_unreached("Error during detect(img): " + error); | 33 assert_unreached("Error during detect(img): " + error); |
| 34 }); | 34 }); |
| 35 | 35 |
| 36 }, 'Detector detect(HTMLImageElement)'); | 36 }, "Detector detect(HTMLImageElement)"); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 function FaceDetectorDetectionResultTest(detectionResult, mock) { | 39 function FaceDetectorDetectionResultTest(detectionResult, mock) { |
| 40 const imageReceivedByMock = mock.getFrameData(); | 40 const imageReceivedByMock = mock.getFrameData(); |
| 41 assert_equals(imageReceivedByMock.byteLength, 2500, "Image length"); | 41 assert_equals(imageReceivedByMock.byteLength, 2500, "Image length"); |
| 42 const GREEN_PIXEL = 0xFF00FF00; | 42 const GREEN_PIXEL = 0xFF00FF00; |
| 43 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color"); | 43 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color"); |
| 44 assert_equals(detectionResult.length, 3, "Number of faces"); | 44 assert_equals(detectionResult.length, 3, "Number of faces"); |
| 45 } | 45 } |
| 46 | 46 |
| 47 function BarcodeDetectorDetectionResultTest(detectionResult, mock) { | 47 function BarcodeDetectorDetectionResultTest(detectionResult, mock) { |
| 48 assert_equals(detectionResult.length, 2, "Number of barcodes"); | 48 assert_equals(detectionResult.length, 2, "Number of barcodes"); |
| 49 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); | 49 assert_equals(detectionResult[0].rawValue, "cats", "barcode 1"); |
| 50 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); | 50 assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2"); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // These tests verify that a Detector's detect() works on an HTMLImageElement. | 53 // These tests verify that a Detector's detect() works on an HTMLImageElement. |
| 54 // Use the mock mojo server implemented in mock-shapedetection.js. | 54 // Use the mock mojo server implemented in mock-shapedetection.js. |
| 55 generate_tests(createTestForImageElement, [ | 55 generate_tests(createTestForImageElement, [ |
| 56 [ "Face", "FaceDetector", FaceDetectorDetectionResultTest ], | 56 [ "Face", "FaceDetector", FaceDetectorDetectionResultTest ], |
| 57 [ "Barcode", "BarcodeDetector", BarcodeDetectorDetectionResultTest ] | 57 [ "Barcode", "BarcodeDetector", BarcodeDetectorDetectionResultTest ] |
| 58 ]); | 58 ]); |
| 59 | 59 |
| 60 </script> | 60 </script> |
| OLD | NEW |