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

Unified Diff: third_party/WebKit/LayoutTests/shapedetection/detectface-ImageBitmap.html

Issue 2448193002: ShapeDetection: support CanvasImageSource as detect() source (Closed)
Patch Set: Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/shapedetection/detectface-ImageBitmap.html
diff --git a/third_party/WebKit/LayoutTests/shapedetection/detectface-ImageBitmap.html b/third_party/WebKit/LayoutTests/shapedetection/detectface-ImageBitmap.html
new file mode 100644
index 0000000000000000000000000000000000000000..6106febf81ba02d52575092781de752f943dde42
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shapedetection/detectface-ImageBitmap.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="../resources/mojo-helpers.js"></script>
+<script src="resources/mock-shapedetection.js"></script>
+<script>
+
+// This test verifies that FaceDetector can detect(ImageBitmap). Uses the mock
+// mojo server under mock-shapedetection.js.
+async_test(function(t) {
+ var img = new Image();
+
+ img.onload = function() {
+ var theImageBitmap = null;
+ var theMock = null;
+
+ createImageBitmap(img)
+ .then(imageBitmap => {
+ theImageBitmap = imageBitmap;
+ return mockShapeDetectionReady;
+ })
+ .catch(error => {
+ assert_unreached('createImageBitmap() error: ' + error);
+ })
+ .then(mock => {
+ theMock = mock;
+ return new FaceDetector();
+ })
+ .catch(error => {
+ assert_unreached("Error creating MockShapeDetection: " + error);
+ })
+ .then(detector => {
+ return detector.detect(theImageBitmap);
+ })
+ .then(faceDetectionResult => {
+ const imageReceivedByMock = theMock.getFrameData();
+ assert_equals(imageReceivedByMock.byteLength, 2500, "imageReceivedByMock.byteLength");
xianglu 2016/10/25 21:07:45 nit: format here
mcasas 2016/10/25 21:47:38 Done.
+ const GREEN_PIXEL = 0xFF00FF00;
+ assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "pixel must be green");
+ assert_equals(faceDetectionResult.length, 3, "faceDetectionResult.length");
+ t.done();
+ })
+ .catch(error => {
+ assert_unreached("Error during detect(img): " + error);
+ });
+ }
+ img.src = '../media/content/greenbox.png';
+}, '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.
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698