forked from mirrors/gecko-dev
Automatic update from web-platform-tests Reland: [shapedetection] Upstream TextDetection tests to WPT The original CL has been reverted because the test external/wpt/shape-detection/idlharness.https.any.shareworker.html is flaky on Mac. This reland CL disables this test on Mac. Original change's description: > [shapedetection] Upstream TextDetection tests to WPT > > This CL upstreams the reset of shapedetection tests(mainly > TextDetection tests) to WPT. > > - Moves tests under > third_party/blink/web_tests/shapedetection/, > third_party/blink/web_tests/fast/shapedetection/, > third_party/blink/web_tests/http/tests/shapedetection/, > to third_party/blink/web_tests/external/wpt/shape-detection. > - Moves third_party/blink/web_tests/shapedetection/resources/mock-textdetection.js > to third_party/blink/web_tests/external/wpt/resources/chromium/. > - Removes third_party/blink/web_tests/fast/shapedetection/shapedetection-creation.html > as which should be covered in idlharness tests. > - Introduces simulateClosedPipe() to MockBarcodeDetectionProvider to simulate > 'no implementation available' case for > third_party/blink/web_tests/external/wpt/shape-detection/detection-getSupportedFormats.https.html > - Improves third_party/blink/web_tests/external/wpt/shape-detection/detection-options.https.html > by using assert_throws_js BTW. > > Bug: 932382 > Change-Id: I2f795e4fa4f23b33c49b7924cdbcbccde5ac6ed4 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131154 > Reviewed-by: Reilly Grant <reillyg@chromium.org> > Commit-Queue: Wanming Lin <wanming.lin@intel.com> > Cr-Commit-Position: refs/heads/master@{#756131} Bug: 932382, 1067533 Change-Id: I85b5dcc841185e2edd20a76ed3aec8add7f08954 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134924 Reviewed-by: Reilly Grant <reillyg@chromium.org> Commit-Queue: Wanming Lin <wanming.lin@intel.com> Cr-Commit-Position: refs/heads/master@{#756647} -- wpt-commits: dfc0080d132ac25c4cf824a25735203b3a2b6853 wpt-pr: 22690
68 lines
2.7 KiB
HTML
68 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="resources/shapedetection-helpers.js"></script>
|
|
<script>
|
|
|
|
// These tests verify that a Detector's detect() works on an ImageBitmap.
|
|
const imageDataTests =
|
|
[
|
|
{
|
|
createDetector: () => { return new FaceDetector(); },
|
|
mockTestName: "FaceDetectionTest",
|
|
detectionResultTest: FaceDetectorDetectionResultTest,
|
|
name: "Face - detect(ImageData)"
|
|
},
|
|
{
|
|
createDetector: () => { return new BarcodeDetector(); },
|
|
mockTestName: "BarcodeDetectionTest",
|
|
detectionResultTest: BarcodeDetectorDetectionResultTest,
|
|
name: "Barcode - detect(ImageData)"
|
|
},
|
|
{
|
|
createDetector: () => { return new TextDetector(); },
|
|
mockTestName: "TextDetectionTest",
|
|
detectionResultTest: TextDetectorDetectionResultTest,
|
|
name: "Text - detect(ImageData)",
|
|
}
|
|
];
|
|
|
|
for (let imageDataTest of imageDataTests) {
|
|
detection_test(imageDataTest.mockTestName, async (t, detectionTest) => {
|
|
const img = new Image();
|
|
const imgWatcher = new EventWatcher(t, img, ["load", "error"]);
|
|
img.src = "/images/green-16x16.png";
|
|
await imgWatcher.wait_for("load");
|
|
const canvas = document.createElement("canvas");
|
|
canvas.getContext("2d").drawImage(img, 0, 0);
|
|
|
|
const detector = imageDataTest.createDetector();
|
|
const detectionResult = await detector.detect(canvas.getContext("2d")
|
|
.getImageData(0, 0, canvas.width, canvas.height));
|
|
imageDataTest.detectionResultTest(detectionResult, detectionTest);
|
|
}, imageDataTest.name);
|
|
}
|
|
|
|
function FaceDetectorDetectionResultTest(detectionResult, mockTest) {
|
|
const imageReceivedByMock = mockTest.MockFaceDetectionProvider().getFrameData();
|
|
assert_equals(imageReceivedByMock.byteLength, 180000,"Image length");
|
|
const GREEN_PIXEL = 0xFF00FF00;
|
|
assert_equals(imageReceivedByMock[0], GREEN_PIXEL, "Pixel color");
|
|
assert_equals(detectionResult.length, 3, "Number of faces");
|
|
}
|
|
|
|
function BarcodeDetectorDetectionResultTest(detectionResult, mockTest) {
|
|
assert_equals(detectionResult.length, 2, "Number of barcodes");
|
|
assert_equals(detectionResult[0].rawValue, "cats", "barcode 1");
|
|
assert_equals(detectionResult[0].format, "qr_code", "barcode 1 format");
|
|
assert_equals(detectionResult[1].rawValue, "dogs", "barcode 2");
|
|
assert_equals(detectionResult[1].format, "code_128", "barcode 2 format");
|
|
}
|
|
|
|
function TextDetectorDetectionResultTest(detectionResult, mockTest) {
|
|
assert_equals(detectionResult.length, 2, "Number of textBlocks");
|
|
assert_equals(detectionResult[0].rawValue, "cats", "textBlock 1");
|
|
assert_equals(detectionResult[1].rawValue, "dogs", "textBlock 2");
|
|
}
|
|
|
|
</script>
|