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

Unified Diff: third_party/WebKit/LayoutTests/shapedetection/detector-same-object.html

Issue 2873453004: Shape Detection: add SaveSameObject idl to SameObject annotations (Closed)
Patch Set: Removed [SaveSameObject] from members where it doesn't make sense Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/shapedetection/DetectedBarcode.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/shapedetection/detector-same-object.html
diff --git a/third_party/WebKit/LayoutTests/shapedetection/detector-same-object.html b/third_party/WebKit/LayoutTests/shapedetection/detector-same-object.html
new file mode 100644
index 0000000000000000000000000000000000000000..1df6e3f5b7863d4ad537d70c4f94de2cfe818f94
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/shapedetection/detector-same-object.html
@@ -0,0 +1,89 @@
+<!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-barcodedetection.js"></script>
+<script src="resources/mock-facedetection.js"></script>
+<script src="resources/mock-textdetection.js"></script>
+<script>
+
+var createTestForImageData = function(createDetector, mockReady,
+ detectionResultTest) {
+ async_test(function(t) {
+
+ var img = new Image();
+ img.onload = function() {
+
+ var canvas = document.createElement("canvas");;
+ canvas.getContext("2d").drawImage(img, 0, 0);
+
+ var theMock = null;
+ mockReady()
+ .then(mock => {
+ theMock = mock;
+ var detector = createDetector();
+ return detector;
+ })
+ .catch(error => {
+ assert_unreached("Error creating Mock Detector: " + error);
+ })
+ .then(detector => {
+ return detector.detect(canvas.getContext("2d").getImageData(
+ 0, 0, canvas.width, canvas.height));
+ })
+ .then(detectionResult => {
+ detectionResultTest(detectionResult);
+ t.done();
+ })
+ .catch(error => {
+ assert_unreached("Error during detect(canvas): " + error);
+ });
+ }
+
+ img.src = "../media/content/greenbox.png";
+ });
+};
+
+function CheckDetectedFaceSameObjects(detectedFaces) {
+ assert_greater_than(detectedFaces.length, 0, "Number of faces");
+ assert_equals(detectedFaces[0].boundingBox, detectedFaces[0].boundingBox);
+ assert_equals(detectedFaces[0].landmarks, detectedFaces[0].landmarks);
+}
+
+function CheckDetectedBarcodesSameObjects(detectedBarcodes) {
+ assert_greater_than(detectedBarcodes.length, 0, "Number of barcodes");
+ assert_equals(detectedBarcodes[0].rawValue, detectedBarcodes[0].rawValue);
+ assert_equals(detectedBarcodes[0].boundingBox, detectedBarcodes[0].boundingBox);
+ assert_equals(detectedBarcodes[0].cornerPoints, detectedBarcodes[0].cornerPoints);
+}
+
+function CheckDetectedTextBlocksSameObjects(detectedTextBlocks) {
+ assert_greater_than(detectedTextBlocks.length, 0, "Number of textBlocks");
+ assert_equals(detectedTextBlocks[0].rawValue, detectedTextBlocks[0].rawValue);
+ assert_equals(detectedTextBlocks[0].boundingBox, detectedTextBlocks[0].boundingBox);
+}
+
+// These tests verify that detect()ed Detected{Barcode,Face,Text}'s individual
+// fields are [SameObject].
+generate_tests(createTestForImageData, [
+ [
+ "Face - detect(ImageData), [SameObject]",
+ () => { return new FaceDetector(); },
+ () => { return mockFaceDetectionProviderReady; },
+ CheckDetectedFaceSameObjects
+ ],
+ [
+ "Barcode - detect(ImageData), [SameObject]",
+ () => { return new BarcodeDetector(); },
+ () => { return mockBarcodeDetectionReady; },
+ CheckDetectedBarcodesSameObjects
+ ],
+ [
+ "Text - detect(ImageData), [SameObject]",
+ () => { return new TextDetector(); },
+ () => { return mockTextDetectionReady; },
+ CheckDetectedTextBlocksSameObjects
+ ]
+]);
+
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/shapedetection/DetectedBarcode.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698