diff options
Diffstat (limited to 'testing/web-platform/tests/shape-detection/resources')
39 files changed, 141 insertions, 0 deletions
diff --git a/testing/web-platform/tests/shape-detection/resources/aztec-correction.jpg b/testing/web-platform/tests/shape-detection/resources/aztec-correction.jpg Binary files differnew file mode 100644 index 0000000000..55bc0d23d6 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/aztec-correction.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/aztec-full.jpg b/testing/web-platform/tests/shape-detection/resources/aztec-full.jpg Binary files differnew file mode 100644 index 0000000000..36390f0821 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/aztec-full.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/aztec-layers.jpg b/testing/web-platform/tests/shape-detection/resources/aztec-layers.jpg Binary files differnew file mode 100644 index 0000000000..75449a7044 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/aztec-layers.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/aztec.jpg b/testing/web-platform/tests/shape-detection/resources/aztec.jpg Binary files differnew file mode 100644 index 0000000000..f71e11f064 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/aztec.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/barcodes.mov b/testing/web-platform/tests/shape-detection/resources/barcodes.mov Binary files differnew file mode 100644 index 0000000000..473a7ae239 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/barcodes.mov diff --git a/testing/web-platform/tests/shape-detection/resources/code128-height.jpg b/testing/web-platform/tests/shape-detection/resources/code128-height.jpg Binary files differnew file mode 100644 index 0000000000..69883e5683 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/code128-height.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/code128.jpg b/testing/web-platform/tests/shape-detection/resources/code128.jpg Binary files differnew file mode 100644 index 0000000000..9bb66fe8ca --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/code128.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/face-bottom-left.jpg b/testing/web-platform/tests/shape-detection/resources/face-bottom-left.jpg Binary files differnew file mode 100644 index 0000000000..1fb4e660e4 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/face-bottom-left.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/face-bottom-right.jpg b/testing/web-platform/tests/shape-detection/resources/face-bottom-right.jpg Binary files differnew file mode 100644 index 0000000000..ce8837851b --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/face-bottom-right.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/face-center.jpg b/testing/web-platform/tests/shape-detection/resources/face-center.jpg Binary files differnew file mode 100644 index 0000000000..30364040ed --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/face-center.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/face-top-left.jpg b/testing/web-platform/tests/shape-detection/resources/face-top-left.jpg Binary files differnew file mode 100644 index 0000000000..300866b2eb --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/face-top-left.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/face-top-right.jpg b/testing/web-platform/tests/shape-detection/resources/face-top-right.jpg Binary files differnew file mode 100644 index 0000000000..528a2a778d --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/face-top-right.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/faces.mov b/testing/web-platform/tests/shape-detection/resources/faces.mov Binary files differnew file mode 100644 index 0000000000..b2c7b8c577 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/faces.mov diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-columns.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-columns.jpg Binary files differnew file mode 100644 index 0000000000..54a08cf0ee --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-columns.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-compact.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-compact.jpg Binary files differnew file mode 100644 index 0000000000..1185c56dfe --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-compact.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-compaction.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-compaction.jpg Binary files differnew file mode 100644 index 0000000000..20e4a1c64c --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-compaction.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-correction.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-correction.jpg Binary files differnew file mode 100644 index 0000000000..0c64ea9605 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-correction.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-rows.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-rows.jpg Binary files differnew file mode 100644 index 0000000000..9f5f67b10c --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-rows.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-square.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-square.jpg Binary files differnew file mode 100644 index 0000000000..8a379ae6cc --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-square.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-taller.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-taller.jpg Binary files differnew file mode 100644 index 0000000000..a520f22fde --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-taller.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417-wider.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417-wider.jpg Binary files differnew file mode 100644 index 0000000000..9f5f67b10c --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417-wider.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/pdf417.jpg b/testing/web-platform/tests/shape-detection/resources/pdf417.jpg Binary files differnew file mode 100644 index 0000000000..ebbe36b510 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/pdf417.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-bottom-left.jpg b/testing/web-platform/tests/shape-detection/resources/qr-bottom-left.jpg Binary files differnew file mode 100644 index 0000000000..754bdedaf1 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-bottom-left.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-bottom-right.jpg b/testing/web-platform/tests/shape-detection/resources/qr-bottom-right.jpg Binary files differnew file mode 100644 index 0000000000..483297100d --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-bottom-right.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-center.jpg b/testing/web-platform/tests/shape-detection/resources/qr-center.jpg Binary files differnew file mode 100644 index 0000000000..ca8e770bf4 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-center.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-h.jpg b/testing/web-platform/tests/shape-detection/resources/qr-h.jpg Binary files differnew file mode 100644 index 0000000000..a1beb02101 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-h.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-l.jpg b/testing/web-platform/tests/shape-detection/resources/qr-l.jpg Binary files differnew file mode 100644 index 0000000000..a29c358393 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-l.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-m.jpg b/testing/web-platform/tests/shape-detection/resources/qr-m.jpg Binary files differnew file mode 100644 index 0000000000..ca8e770bf4 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-m.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-q.jpg b/testing/web-platform/tests/shape-detection/resources/qr-q.jpg Binary files differnew file mode 100644 index 0000000000..45313c71b0 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-q.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-top-left.jpg b/testing/web-platform/tests/shape-detection/resources/qr-top-left.jpg Binary files differnew file mode 100644 index 0000000000..f3092933e4 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-top-left.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/qr-top-right.jpg b/testing/web-platform/tests/shape-detection/resources/qr-top-right.jpg Binary files differnew file mode 100644 index 0000000000..875ee8035c --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/qr-top-right.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/shapedetection-helpers.js b/testing/web-platform/tests/shape-detection/resources/shapedetection-helpers.js new file mode 100644 index 0000000000..1b4949b8f6 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/shapedetection-helpers.js @@ -0,0 +1,75 @@ +'use strict'; + +// These tests rely on the User Agent providing an implementation of +// platform shape detection backends. +// +// In Chromium-based browsers this implementation is provided by a polyfill +// in order to reduce the amount of test-only code shipped to users. To enable +// these tests the browser must be run with these options: +// +// --enable-blink-features=MojoJS,MojoJSTest + +async function loadChromiumResources() { + await import('/resources/chromium/mock-barcodedetection.js'); + await import('/resources/chromium/mock-facedetection.js'); + await import('/resources/chromium/mock-textdetection.js'); +} + +/** + * @param {String} detectionTestName + * name of mock shape detection test interface, + * must be the item of ["FaceDetectionTest", "BarcodeDetectionTest", + * "TextDetectionTest"] +*/ +async function initialize_detection_tests(detectionTestName) { + let detectionTest; + if (typeof document === 'undefined') { + // Use 'self' for workers. + if (typeof self[detectionTestName] === 'undefined') { + // test-only-api.js is already loaded in worker.js + if (isChromiumBased) { + await loadChromiumResources(); + } + } + detectionTest = new self[detectionTestName](); + } else { + if (typeof window[detectionTestName] === 'undefined') { + const script = document.createElement('script'); + script.src = '/resources/test-only-api.js'; + script.async = false; + const p = new Promise((resolve, reject) => { + script.onload = () => { resolve(); }; + script.onerror = e => { reject(e); }; + }) + document.head.appendChild(script); + await p; + + if (isChromiumBased) { + await loadChromiumResources(); + } + + } + detectionTest = new window[detectionTestName](); + } + await detectionTest.initialize(); + return detectionTest; +} + +function detection_test(detectionTestName, func, name, properties) { + promise_test(async t => { + let detectionTest = await initialize_detection_tests(detectionTestName); + try { + await func(t, detectionTest); + } finally { + await detectionTest.reset(); + }; + }, name, properties); +} + +function getArrayBufferFromBigBuffer(bigBuffer) { + if (bigBuffer.bytes !== undefined) { + return new Uint8Array(bigBuffer.bytes).buffer; + } + return bigBuffer.sharedMemory.bufferHandle.mapBuffer(0, + bigBuffer.sharedMemory.size).buffer; +} diff --git a/testing/web-platform/tests/shape-detection/resources/single-detection-helpers.js b/testing/web-platform/tests/shape-detection/resources/single-detection-helpers.js new file mode 100644 index 0000000000..bbd2bda96b --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/single-detection-helpers.js @@ -0,0 +1,66 @@ +function imageLoadedPromise(image) { + return new Promise(function(resolve, reject) { + if (image.complete) + resolve(); + image.addEventListener("load", resolve, { once: true }); + }); +} + +function videoLoadedPromise(video) { + return new Promise(function(resolve, reject) { + if (video.readyState == 4) + resolve(); + else { + video.addEventListener("loadeddata", resolve, { once: true }); + video.addEventListener("error", reject, { once: true }); + } + }); +} + +function waitForNFrames(count) { + if (count <= 0) + return Promise.reject(new TypeError("count should be greater than 0!")); + + return new Promise(resolve => { + function tick() { + (--count) ? requestAnimationFrame(tick) : resolve(); + } + requestAnimationFrame(tick); + }); +} + +function seekTo(video, time) { + return new Promise(function(resolve, reject) { + video.addEventListener("seeked", async function() { + /* Work around flakiness in video players... */ + await waitForNFrames(3); + resolve(); + }, { once: true }); + video.currentTime = time; + }); +} + +function checkBoundingBox(actual, expected, fuzziness) { + assert_equals(actual.constructor.name, "DOMRectReadOnly"); + assert_approx_equals(actual.left, expected.left, fuzziness); + assert_approx_equals(actual.right, expected.right, fuzziness); + assert_approx_equals(actual.top, expected.top, fuzziness); + assert_approx_equals(actual.bottom, expected.bottom, fuzziness); +} + +function checkPointsLieWithinBoundingBox(points, boundingBox) { + for (point of points) { + assert_between_inclusive(point.x, boundingBox.left, boundingBox.right); + assert_between_inclusive(point.y, boundingBox.top, boundingBox.bottom); + } +} + +function checkPointIsNear(actual, expected, fuzzinessX, fuzzinessY) { + assert_approx_equals(actual.x, expected.x, fuzzinessX); + assert_approx_equals(actual.y, expected.y, fuzzinessY); +} + +function checkPointsAreNear(actual, expected, fuzzinessX, fuzzinessY) { + for (point of actual) + checkPointIsNear(point, expected, fuzzinessX, fuzzinessY); +} diff --git a/testing/web-platform/tests/shape-detection/resources/text-bottom-left.jpg b/testing/web-platform/tests/shape-detection/resources/text-bottom-left.jpg Binary files differnew file mode 100644 index 0000000000..12a0641fd3 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/text-bottom-left.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/text-bottom-right.jpg b/testing/web-platform/tests/shape-detection/resources/text-bottom-right.jpg Binary files differnew file mode 100644 index 0000000000..7ad8b71b6c --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/text-bottom-right.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/text-center.jpg b/testing/web-platform/tests/shape-detection/resources/text-center.jpg Binary files differnew file mode 100644 index 0000000000..69e8ce446c --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/text-center.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/text-top-left.jpg b/testing/web-platform/tests/shape-detection/resources/text-top-left.jpg Binary files differnew file mode 100644 index 0000000000..53ca0e0aaf --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/text-top-left.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/text-top-right.jpg b/testing/web-platform/tests/shape-detection/resources/text-top-right.jpg Binary files differnew file mode 100644 index 0000000000..76a22a677c --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/text-top-right.jpg diff --git a/testing/web-platform/tests/shape-detection/resources/text.mov b/testing/web-platform/tests/shape-detection/resources/text.mov Binary files differnew file mode 100644 index 0000000000..d50197b326 --- /dev/null +++ b/testing/web-platform/tests/shape-detection/resources/text.mov |