Chromium Code Reviews| 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> | 4 <script> |
| 5 | 5 |
| 6 // This test verifies FaceDetector.detect() with an empty HTMLImageElement. | 6 // This test verifies FaceDetector.detect() with an empty HTMLImageElement. |
| 7 async_test(function(t) { | 7 var makeAsyncTest = function(detectorName) { |
|
xianglu
2016/11/15 19:19:29
Consider changing this name to something more expl
mcasas
2016/11/15 20:22:55
Done renaming after offline discussion.
| |
| 8 var image = new Image(); | 8 async_test(function(t) { |
| 9 var faceDetector = new FaceDetector(); | 9 var image = new Image(); |
| 10 var tryFaceDetection = function() { | 10 var detector = eval("new " + detectorName + "();"); |
| 11 faceDetector.detect(image) | 11 var tryDetection = function() { |
| 12 .then(faceDetectionResult => { | 12 detector.detect(image) |
| 13 assert_equals(faceDetectionResult.length, 0); | 13 .then(detectionResult => { |
| 14 t.done(); | 14 assert_equals(detectionResult.length, 0); |
| 15 }) | 15 t.done(); |
| 16 .catch(error => { | 16 }) |
| 17 assert_unreached("detect() rejected with error: " + error) | 17 .catch(error => { |
| 18 }); | 18 assert_unreached("detect() rejected with error: " + error) |
| 19 }; | 19 }); |
| 20 image.onload = tryFaceDetection; | 20 }; |
| 21 image.onerror = tryFaceDetection; | 21 image.onload = tryDetection; |
| 22 image.src = ""; | 22 image.onerror = tryDetection; |
| 23 }, "FaceDetector should resolve empty images with empty results."); | 23 image.src = ""; |
| 24 }, "Detectors should resolve empty images with empty results."); | |
| 25 }; | |
| 26 | |
| 27 generate_tests(makeAsyncTest, [["Face", "FaceDetector"], | |
| 28 ["Barcode", "BarcodeDetector"]]); | |
| 24 | 29 |
| 25 </script> | 30 </script> |
| OLD | NEW |