diff options
| author | dehnhard <info@dehnhard.it> | 2021-04-02 01:04:55 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-02 01:04:55 +0300 |
| commit | 3bf945e4cf58ac8c47931161e670fec16880aeed (patch) | |
| tree | 7a0646cfa881ae8e2003b612c3a83e89dab1b757 /core/src/test/java/com | |
| parent | 5fb2cf8e96af250fa6bfc472ef7e1669fa41a2f3 (diff) | |
| download | zxing-3bf945e4cf58ac8c47931161e670fec16880aeed.tar.xz | |
inverted barcode support (#1371)
* also decodes inverted barcode on hint
Co-authored-by: Daniel Dehnhard <daniel@dehnhard.it>
Diffstat (limited to 'core/src/test/java/com')
3 files changed, 78 insertions, 1 deletions
diff --git a/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java b/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java index cc2374371..f295f31dc 100644 --- a/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java +++ b/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java @@ -62,6 +62,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert { private final Reader barcodeReader; private final BarcodeFormat expectedFormat; private final List<TestResult> testResults; + private final EnumMap<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class); public static Path buildTestBase(String testBasePathSuffix) { // A little workaround to prevent aggravation in my IDE @@ -92,6 +93,10 @@ public abstract class AbstractBlackBoxTestCase extends Assert { addTest(mustPassCount, tryHarderCount, 0, 0, rotation); } + protected void addHint(DecodeHintType hint) { + hints.put(hint, Boolean.TRUE); + } + /** * Adds a new test for the current directory of images. * @@ -252,7 +257,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert { String suffix = String.format(" (%srotation: %d)", tryHarder ? "try harder, " : "", (int) rotation); - Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class); + Map<DecodeHintType,Object> hints = this.hints.clone(); if (tryHarder) { hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); } diff --git a/core/src/test/java/com/google/zxing/inverted/InvertedDataMatrixBlackBoxTestCase.java b/core/src/test/java/com/google/zxing/inverted/InvertedDataMatrixBlackBoxTestCase.java new file mode 100644 index 000000000..c2c942e44 --- /dev/null +++ b/core/src/test/java/com/google/zxing/inverted/InvertedDataMatrixBlackBoxTestCase.java @@ -0,0 +1,38 @@ +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.zxing.inverted; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.DecodeHintType; +import com.google.zxing.MultiFormatReader; +import com.google.zxing.common.AbstractBlackBoxTestCase; + +/** + * Inverted barcodes + */ +public final class InvertedDataMatrixBlackBoxTestCase extends AbstractBlackBoxTestCase { + + public InvertedDataMatrixBlackBoxTestCase() { + super("src/test/resources/blackbox/inverted", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); + addHint(DecodeHintType.ALSO_INVERTED); + addTest(1, 1, 0.0f); + addTest(1, 1, 90.0f); + addTest(1, 1, 180.0f); + addTest(1, 1, 270.0f); + } + +} diff --git a/core/src/test/java/com/google/zxing/inverted/NoHintInvertedDataMatrixBlackBoxTestCase.java b/core/src/test/java/com/google/zxing/inverted/NoHintInvertedDataMatrixBlackBoxTestCase.java new file mode 100644 index 000000000..ca3a6b2c2 --- /dev/null +++ b/core/src/test/java/com/google/zxing/inverted/NoHintInvertedDataMatrixBlackBoxTestCase.java @@ -0,0 +1,34 @@ +/* + * Copyright 2008 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.zxing.inverted; + +import com.google.zxing.common.AbstractNegativeBlackBoxTestCase; + +/** + * Without hint inverted barcodes should not be found. + */ +public final class NoHintInvertedDataMatrixBlackBoxTestCase extends AbstractNegativeBlackBoxTestCase { + + public NoHintInvertedDataMatrixBlackBoxTestCase() { + super("src/test/resources/blackbox/inverted"); + addTest(0, 0.0f); + addTest(0, 90.0f); + addTest(0, 180.0f); + addTest(0, 270.0f); + } + +} |
