Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2384)

Side by Side Diff: third_party/WebKit/LayoutTests/shapedetection/detectface-HTMLImageElement.html

Issue 2448193002: ShapeDetection: support CanvasImageSource as detect() source (Closed)
Patch Set: esprehn@ comments and specific LayoutTest for empty HTMLImageElement Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 // This test verifies that FaceDetector can detect(). A mock mojo 11 // This test verifies that FaceDetector can detect(HTMLImageElement). Uses the
12 // server is implemented in mock-shapedetection.js. 12 // mock mojo server implemented in mock-shapedetection.js.
13
14 async_test(function(t) { 13 async_test(function(t) {
15 var img = document.getElementById("img"); 14 var img = document.getElementById("img");
16 15
17 var theMock = null; 16 var theMock = null;
18 mockShapeDetectionReady 17 mockShapeDetectionReady
19 .then(mock => { 18 .then(mock => {
20 theMock = mock; 19 theMock = mock;
21 return new FaceDetector(); 20 return new FaceDetector();
22 }) 21 })
23 .catch(error => { 22 .catch(error => {
24 assert_unreached("Error creating MockShapeDetection: " + error); 23 assert_unreached("Error creating MockShapeDetection: " + error);
25 }) 24 })
26 .then(detector => { 25 .then(detector => {
27 return detector.detect(img); 26 return detector.detect(img);
28 }) 27 })
29 .then(faceDetectionResult => { 28 .then(faceDetectionResult => {
30 const imageReceivedByMock = theMock.getFrameData(); 29 const imageReceivedByMock = theMock.getFrameData();
31 assert_equals(imageReceivedByMock.byteLength, 2500, "imageReceivedByMock.b yteLength"); 30 assert_equals(imageReceivedByMock.byteLength, 2500,
31 "imageReceivedByMock.byteLength");
32 const GREEN_PIXEL = 0xFF00FF00; 32 const GREEN_PIXEL = 0xFF00FF00;
33 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be green"); 33 assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be green");
34 assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.length") ; 34 assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.length") ;
35 t.done(); 35 t.done();
36 }) 36 })
37 .catch(error => { 37 .catch(error => {
38 assert_unreached("Error during detect(img): " + error); 38 assert_unreached("Error during detect(img): " + error);
39 }); 39 });
40 40
41 }, 'exercises the ShapeDetection API detect()'); 41 }, 'exercises the ShapeDetection API detect(HTMLImageElement)');
42 42
43 </script> 43 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698