Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="../resources/mojo-helpers.js"></script> | |
| 5 <script src="resources/mock-shapedetection.js"></script> | |
| 6 <script> | |
| 7 | |
| 8 // This test verifies that FaceDetector can detect(ImageBitmap). Uses the mock | |
| 9 // mojo server under mock-shapedetection.js. | |
| 10 async_test(function(t) { | |
| 11 var img = new Image(); | |
| 12 | |
| 13 img.onload = function() { | |
| 14 var theImageBitmap = null; | |
| 15 var theMock = null; | |
| 16 | |
| 17 createImageBitmap(img) | |
| 18 .then(imageBitmap => { | |
| 19 theImageBitmap = imageBitmap; | |
| 20 return mockShapeDetectionReady; | |
| 21 }) | |
| 22 .catch(error => { | |
| 23 assert_unreached('createImageBitmap() error: ' + error); | |
| 24 }) | |
| 25 .then(mock => { | |
| 26 theMock = mock; | |
| 27 return new FaceDetector(); | |
| 28 }) | |
| 29 .catch(error => { | |
| 30 assert_unreached("Error creating MockShapeDetection: " + error); | |
| 31 }) | |
| 32 .then(detector => { | |
| 33 return detector.detect(theImageBitmap); | |
| 34 }) | |
| 35 .then(faceDetectionResult => { | |
| 36 const imageReceivedByMock = theMock.getFrameData(); | |
| 37 assert_equals(imageReceivedByMock.byteLength, 2500, "imageReceivedByMo ck.byteLength"); | |
|
xianglu
2016/10/25 21:07:45
nit: format here
mcasas
2016/10/25 21:47:38
Done.
| |
| 38 const GREEN_PIXEL = 0xFF00FF00; | |
| 39 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be gree n"); | |
| 40 assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.leng th"); | |
| 41 t.done(); | |
| 42 }) | |
| 43 .catch(error => { | |
| 44 assert_unreached("Error during detect(img): " + error); | |
| 45 }); | |
| 46 } | |
| 47 img.src = '../media/content/greenbox.png'; | |
| 48 }, 'exercises the ShapeDetection API detect()'); | |
|
xianglu
2016/10/25 21:07:45
nit: 'exercises the ShapeDetection API detect(Imag
mcasas
2016/10/25 21:47:38
Done.
| |
| 49 | |
| 50 </script> | |
| OLD | NEW |