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 <body> | 7 <body> |
8 <img id='img' src='../media/content/greenbox.png'/> | 8 <img id='img' src='../media/content/greenbox.png'/> |
9 </body> | 9 </body> |
10 <script> | 10 <script> |
11 | 11 |
12 var createTestForImageElement = function(detectorName, mockReady, | 12 var createTestForImageElement = function(detectorName, mockReady, |
13 detectionResultTest) { | 13 detectionResultTest) { |
14 async_test(function(t) { | 14 async_test(function(t) { |
15 var img = document.getElementById("img"); | 15 var img = document.getElementById("img"); |
16 | 16 |
17 var theMock = null; | 17 var theMock = null; |
18 mockReady() | 18 mockReady() |
19 .then(mock => { | 19 .then(mock => { |
20 theMock = mock; | 20 theMock = mock; |
21 var detector = eval("new " + detectorName + "();"); | 21 var detector = eval("new " + detectorName + "();"); |
22 return detector; | 22 return detector; |
23 }) | 23 }) |
24 .catch(error => { | 24 .catch(error => { |
25 assert_unreached("Error creating MockFaceDetection: " + error); | 25 assert_unreached("Error creating Mock Detector: " + error); |
26 }) | 26 }) |
27 .then(detector => { | 27 .then(detector => { |
28 return detector.detect(img); | 28 return detector.detect(img); |
29 }) | 29 }) |
30 .then(detectionResult => { | 30 .then(detectionResult => { |
31 detectionResultTest(detectionResult, theMock); | 31 detectionResultTest(detectionResult, theMock); |
32 t.done(); | 32 t.done(); |
33 }) | 33 }) |
34 .catch(error => { | 34 .catch(error => { |
35 assert_unreached("Error during detect(img): " + error); | 35 assert_unreached("Error during detect(img): " + error); |
(...skipping 27 matching lines...) Expand all Loading... |
63 ], | 63 ], |
64 [ | 64 [ |
65 "Barcode", | 65 "Barcode", |
66 "BarcodeDetector", | 66 "BarcodeDetector", |
67 () => { return mockBarcodeDetectionReady; }, | 67 () => { return mockBarcodeDetectionReady; }, |
68 BarcodeDetectorDetectionResultTest | 68 BarcodeDetectorDetectionResultTest |
69 ] | 69 ] |
70 ]); | 70 ]); |
71 | 71 |
72 </script> | 72 </script> |
OLD | NEW |