From 30dc420bab72f044c923ab928a27b4fda72315a8 Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Sun, 11 Sep 2016 13:44:13 +0100 Subject: [PATCH] More coverage for Code93/39 writers, and for multiple barcode detection --- .../common/AbstractBlackBoxTestCase.java | 12 ++-- .../zxing/common/BitMatrixTestCase.java | 9 +++ .../com/google/zxing/multi/MultiTestCase.java | 58 ++++++++++++++++++ .../multi/qrcode/MultiQRCodeTestCase.java | 8 +-- .../zxing/oned/CodaBarWriterTestCase.java | 7 +-- .../zxing/oned/Code128WriterTestCase.java | 17 ++--- .../zxing/oned/Code39WriterTestCase.java | 44 +++++++++++++ .../zxing/oned/Code93WriterTestCase.java | 43 +++++++++++++ .../zxing/oned/EAN13WriterTestCase.java | 7 +-- .../google/zxing/oned/EAN8WriterTestCase.java | 7 +-- .../google/zxing/oned/UPCAWriterTestCase.java | 13 ++-- .../RSSExpandedImage2binaryTestCase.java | 9 +-- .../RSSExpandedImage2resultTestCase.java | 9 +-- .../RSSExpandedImage2stringTestCase.java | 9 +-- .../expanded/RSSExpandedInternalTestCase.java | 10 +-- .../zxing/oned/rss/expanded/TestCaseUtil.java | 9 +-- .../src/test/resources/blackbox/multi-1/1.png | Bin 0 -> 10351 bytes 17 files changed, 193 insertions(+), 78 deletions(-) create mode 100644 core/src/test/java/com/google/zxing/multi/MultiTestCase.java create mode 100644 core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java create mode 100644 core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java create mode 100644 core/src/test/resources/blackbox/multi-1/1.png 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 5cc526627..d1a0eb5d4 100644 --- a/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java +++ b/core/src/test/java/com/google/zxing/common/AbstractBlackBoxTestCase.java @@ -63,16 +63,20 @@ public abstract class AbstractBlackBoxTestCase extends Assert { private final BarcodeFormat expectedFormat; private final List testResults; - protected AbstractBlackBoxTestCase(String testBasePathSuffix, - Reader barcodeReader, - BarcodeFormat expectedFormat) { + public static Path buildTestBase(String testBasePathSuffix) { // A little workaround to prevent aggravation in my IDE Path testBase = Paths.get(testBasePathSuffix); if (!Files.exists(testBase)) { // try starting with 'core' since the test base is often given as the project root testBase = Paths.get("core").resolve(testBasePathSuffix); } - this.testBase = testBase; + return testBase; + } + + protected AbstractBlackBoxTestCase(String testBasePathSuffix, + Reader barcodeReader, + BarcodeFormat expectedFormat) { + this.testBase = buildTestBase(testBasePathSuffix); this.barcodeReader = barcodeReader; this.expectedFormat = expectedFormat; testResults = new ArrayList<>(); diff --git a/core/src/test/java/com/google/zxing/common/BitMatrixTestCase.java b/core/src/test/java/com/google/zxing/common/BitMatrixTestCase.java index 5fa248366..6c366555f 100644 --- a/core/src/test/java/com/google/zxing/common/BitMatrixTestCase.java +++ b/core/src/test/java/com/google/zxing/common/BitMatrixTestCase.java @@ -264,6 +264,15 @@ public final class BitMatrixTestCase extends Assert { } } + public static String matrixToString(BitMatrix result) { + assertEquals(1, result.getHeight()); + StringBuilder builder = new StringBuilder(result.getWidth()); + for (int i = 0; i < result.getWidth(); i++) { + builder.append(result.get(i, 0) ? '1' : '0'); + } + return builder.toString(); + } + private static void testXOR(BitMatrix dataMatrix, BitMatrix flipMatrix, BitMatrix expectedMatrix) { BitMatrix matrix = dataMatrix.clone(); matrix.xor(flipMatrix); diff --git a/core/src/test/java/com/google/zxing/multi/MultiTestCase.java b/core/src/test/java/com/google/zxing/multi/MultiTestCase.java new file mode 100644 index 000000000..9497698d5 --- /dev/null +++ b/core/src/test/java/com/google/zxing/multi/MultiTestCase.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 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.multi; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.nio.file.Path; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.BinaryBitmap; +import com.google.zxing.BufferedImageLuminanceSource; +import com.google.zxing.LuminanceSource; +import com.google.zxing.MultiFormatReader; +import com.google.zxing.Result; +import com.google.zxing.common.AbstractBlackBoxTestCase; +import com.google.zxing.common.HybridBinarizer; +import org.junit.Assert; +import org.junit.Test; + +public final class MultiTestCase extends Assert { + + @Test + public void testMulti() throws Exception { + // Very basic test for now + Path testBase = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/multi-1"); + + Path testImage = testBase.resolve("1.png"); + BufferedImage image = ImageIO.read(testImage.toFile()); + LuminanceSource source = new BufferedImageLuminanceSource(image); + BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); + + MultipleBarcodeReader reader = new GenericMultipleBarcodeReader(new MultiFormatReader()); + Result[] results = reader.decodeMultiple(bitmap); + assertNotNull(results); + assertEquals(2, results.length); + + assertEquals("031415926531", results[0].getText()); + assertEquals(BarcodeFormat.UPC_A, results[0].getBarcodeFormat()); + + assertEquals("www.airtable.com/jobs", results[1].getText()); + assertEquals(BarcodeFormat.QR_CODE, results[1].getBarcodeFormat()); + } + +} diff --git a/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java b/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java index 34e6029e4..3b5f4400d 100644 --- a/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java +++ b/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java @@ -18,9 +18,7 @@ package com.google.zxing.multi.qrcode; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -31,6 +29,7 @@ import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.LuminanceSource; import com.google.zxing.Result; import com.google.zxing.ResultMetadataType; +import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.HybridBinarizer; import com.google.zxing.multi.MultipleBarcodeReader; import org.junit.Assert; @@ -41,10 +40,7 @@ public final class MultiQRCodeTestCase extends Assert { @Test public void testMultiQRCodes() throws Exception { // Very basic test for now - Path testBase = Paths.get("src/test/resources/blackbox/multi-qrcode-1"); - if (!Files.exists(testBase)) { - testBase = Paths.get("core").resolve(testBase); - } + Path testBase = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/multi-qrcode-1"); Path testImage = testBase.resolve("1.png"); BufferedImage image = ImageIO.read(testImage.toFile()); diff --git a/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java b/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java index 7971b7e1d..ba22a1b6f 100644 --- a/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/CodaBarWriterTestCase.java @@ -19,6 +19,7 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; import org.junit.Test; @@ -52,11 +53,7 @@ public final class CodaBarWriterTestCase extends Assert { private static void doTest(String input, CharSequence expected) throws WriterException { BitMatrix result = encode(input); - StringBuilder actual = new StringBuilder(result.getWidth()); - for (int i = 0; i < result.getWidth(); i++) { - actual.append(result.get(i, 0) ? '1' : '0'); - } - assertEquals(expected, actual.toString()); + assertEquals(expected, BitMatrixTestCase.matrixToString(result)); } private static BitMatrix encode(String input) throws WriterException { diff --git a/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java index d5352c662..bfb559d6e 100644 --- a/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/Code128WriterTestCase.java @@ -16,6 +16,7 @@ package com.google.zxing.oned; +import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -56,7 +57,7 @@ public class Code128WriterTestCase extends Assert { BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); - String actual = matrixToString(result); + String actual = BitMatrixTestCase.matrixToString(result); assertEquals(expected, actual); } @@ -68,7 +69,7 @@ public class Code128WriterTestCase extends Assert { BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); - String actual = matrixToString(result); + String actual = BitMatrixTestCase.matrixToString(result); assertEquals(expected, actual); } @@ -80,7 +81,7 @@ public class Code128WriterTestCase extends Assert { BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); - String actual = matrixToString(result); + String actual = BitMatrixTestCase.matrixToString(result); assertEquals(expected, actual); } @@ -104,15 +105,9 @@ public class Code128WriterTestCase extends Assert { BitMatrix result = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); - String actual = matrixToString(result); + String actual = BitMatrixTestCase.matrixToString(result); assertEquals(expected, actual); } - private static String matrixToString(BitMatrix result) { - StringBuilder builder = new StringBuilder(result.getWidth()); - for (int i = 0; i < result.getWidth(); i++) { - builder.append(result.get(i, 0) ? '1' : '0'); - } - return builder.toString(); - } + } diff --git a/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java new file mode 100644 index 000000000..b2511b448 --- /dev/null +++ b/core/src/test/java/com/google/zxing/oned/Code39WriterTestCase.java @@ -0,0 +1,44 @@ +/* + * Copyright 2016 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.oned; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.WriterException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.BitMatrixTestCase; +import org.junit.Assert; +import org.junit.Test; + +public final class Code39WriterTestCase extends Assert { + + @Test + public void testEncode() throws WriterException { + doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", + "000001001011011010110101001011010110100101101101101001010101011001011011010110010101" + + "011011001010101010011011011010100110101011010011010101011001101011010101001101011010" + + "100110110110101001010101101001101101011010010101101101001010101011001101101010110010" + + "101101011001010101101100101100101010110100110101011011001101010101001011010110110010" + + "110101010011011010101010011011010110100101011010110010101101101100101010101001101011" + + "01101001101010101100110101010100101101101101001011010101100101101010010110110100000"); + } + + private static void doTest(String input, CharSequence expected) throws WriterException { + BitMatrix result = new Code39Writer().encode(input, BarcodeFormat.CODE_39, 0, 0); + assertEquals(expected, BitMatrixTestCase.matrixToString(result)); + } + +} diff --git a/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java new file mode 100644 index 000000000..e081f1577 --- /dev/null +++ b/core/src/test/java/com/google/zxing/oned/Code93WriterTestCase.java @@ -0,0 +1,43 @@ +/* + * Copyright 2016 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.oned; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.WriterException; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.BitMatrixTestCase; +import org.junit.Assert; +import org.junit.Test; + +public final class Code93WriterTestCase extends Assert { + + @Test + public void testEncode() throws WriterException { + doTest("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", + "000001010111101101010001101001001101000101100101001100100101100010101011010001011001" + + "001011000101001101001000110101010110001010011001010001101001011001000101101101101001" + + "101100101101011001101001101100101101100110101011011001011001101001101101001110101000" + + "101001010010001010001001010000101001010001001001001001000101010100001000100101000010" + + "10100111010101000010101011110100000"); + } + + private static void doTest(String input, CharSequence expected) throws WriterException { + BitMatrix result = new Code93Writer().encode(input, BarcodeFormat.CODE_93, 0, 0); + assertEquals(expected, BitMatrixTestCase.matrixToString(result)); + } + +} diff --git a/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java index 6c1624910..bac2cd980 100644 --- a/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/EAN13WriterTestCase.java @@ -19,6 +19,7 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; import org.junit.Test; @@ -29,11 +30,9 @@ public final class EAN13WriterTestCase extends Assert { @Test public void testEncode() throws WriterException { - CharSequence testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000"; + String testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000"; BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0); - for (int i = 0; i < testStr.length(); i++) { - assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); - } + assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } } diff --git a/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java b/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java index 59ea75846..a5ab2d198 100644 --- a/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/EAN8WriterTestCase.java @@ -19,6 +19,7 @@ package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; import org.junit.Test; @@ -29,11 +30,9 @@ public final class EAN8WriterTestCase extends Assert { @Test public void testEncode() throws WriterException { - CharSequence testStr = "0001010001011010111101111010110111010101001110111001010001001011100101000"; + String testStr = "0001010001011010111101111010110111010101001110111001010001001011100101000"; BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0); - for (int i = 0; i < testStr.length(); i++) { - assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); - } + assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } } diff --git a/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java b/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java index 0bbdaa8bf..7a9c7c7ff 100644 --- a/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/UPCAWriterTestCase.java @@ -20,6 +20,7 @@ import com.google.zxing.BarcodeFormat; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; +import com.google.zxing.common.BitMatrixTestCase; import org.junit.Assert; import org.junit.Test; @@ -30,20 +31,16 @@ public final class UPCAWriterTestCase extends Assert { @Test public void testEncode() throws WriterException { - CharSequence testStr = "00010101000110110111011000100010110101111011110101010111001011101001001110110011011011001011100101000"; + String testStr = "00010101000110110111011000100010110101111011110101010111001011101001001110110011011011001011100101000"; BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0); - for (int i = 0; i < testStr.length(); i++) { - assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); - } + assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } @Test public void testAddChecksumAndEncode() throws WriterException { - CharSequence testStr = "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000"; + String testStr = "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000"; BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0); - for (int i = 0; i < testStr.length(); i++) { - assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); - } + assertEquals(testStr, BitMatrixTestCase.matrixToString(result)); } } diff --git a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2binaryTestCase.java b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2binaryTestCase.java index 07b5a4d63..92001fd7e 100644 --- a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2binaryTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2binaryTestCase.java @@ -28,9 +28,7 @@ package com.google.zxing.oned.rss.expanded; import java.awt.image.BufferedImage; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; import javax.imageio.ImageIO; @@ -39,6 +37,7 @@ import com.google.zxing.BinaryBitmap; import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.NotFoundException; import com.google.zxing.ReaderException; +import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.BitArray; import com.google.zxing.common.GlobalHistogramBinarizer; import org.junit.Assert; @@ -176,11 +175,7 @@ public final class RSSExpandedImage2binaryTestCase extends Assert { private static void assertCorrectImage2binary(String fileName, String expected) throws IOException, NotFoundException { - Path path = Paths.get("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - if (!Files.exists(path)) { - // Support running from project root too - path = Paths.get("core").resolve(path); - } + Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); BufferedImage image = ImageIO.read(path.toFile()); BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); diff --git a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java index dbf405cb6..776b9c291 100644 --- a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java @@ -33,9 +33,7 @@ package com.google.zxing.oned.rss.expanded; import java.awt.image.BufferedImage; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashMap; import javax.imageio.ImageIO; @@ -49,6 +47,7 @@ import com.google.zxing.Result; import com.google.zxing.client.result.ExpandedProductParsedResult; import com.google.zxing.client.result.ParsedResult; import com.google.zxing.client.result.ResultParser; +import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.BitArray; import com.google.zxing.common.GlobalHistogramBinarizer; @@ -77,11 +76,7 @@ public final class RSSExpandedImage2resultTestCase extends Assert { private static void assertCorrectImage2result(String fileName, ExpandedProductParsedResult expected) throws IOException, NotFoundException { - Path path = Paths.get("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - if (!Files.exists(path)) { - // Support running from project root too - path = Paths.get("core").resolve(path); - } + Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); BufferedImage image = ImageIO.read(path.toFile()); BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image))); diff --git a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2stringTestCase.java b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2stringTestCase.java index 3c76c3216..d99f86696 100644 --- a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2stringTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2stringTestCase.java @@ -28,9 +28,7 @@ package com.google.zxing.oned.rss.expanded; import java.awt.image.BufferedImage; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import javax.imageio.ImageIO; @@ -40,6 +38,7 @@ import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.NotFoundException; import com.google.zxing.ReaderException; import com.google.zxing.Result; +import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.BitArray; import com.google.zxing.common.GlobalHistogramBinarizer; import org.junit.Assert; @@ -189,11 +188,7 @@ public final class RSSExpandedImage2stringTestCase extends Assert { private static void assertCorrectImage2string(String fileName, String expected) throws IOException, NotFoundException { - Path path = Paths.get("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - if (!Files.exists(path)) { - // Support running from project root too - path = Paths.get("core").resolve(path); - } + Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); BufferedImage image = ImageIO.read(path.toFile()); BinaryBitmap binaryMap = diff --git a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedInternalTestCase.java b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedInternalTestCase.java index c53e0d5c3..af63d7f33 100644 --- a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedInternalTestCase.java +++ b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedInternalTestCase.java @@ -28,9 +28,7 @@ package com.google.zxing.oned.rss.expanded; import java.awt.image.BufferedImage; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -39,6 +37,7 @@ import javax.imageio.ImageIO; import com.google.zxing.BinaryBitmap; import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.NotFoundException; +import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.BitArray; import com.google.zxing.common.GlobalHistogramBinarizer; import com.google.zxing.oned.rss.DataCharacter; @@ -145,12 +144,7 @@ public final class RSSExpandedInternalTestCase extends Assert { } private static BufferedImage readImage(String fileName) throws IOException { - Path path = Paths.get("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); - if (!Files.exists(path)) { - // Support running from project root too - path = Paths.get("core").resolve(path); - } - + Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); return ImageIO.read(path.toFile()); } diff --git a/core/src/test/java/com/google/zxing/oned/rss/expanded/TestCaseUtil.java b/core/src/test/java/com/google/zxing/oned/rss/expanded/TestCaseUtil.java index 29a08b7a2..dc4af85da 100644 --- a/core/src/test/java/com/google/zxing/oned/rss/expanded/TestCaseUtil.java +++ b/core/src/test/java/com/google/zxing/oned/rss/expanded/TestCaseUtil.java @@ -28,14 +28,13 @@ package com.google.zxing.oned.rss.expanded; import java.awt.image.BufferedImage; import java.io.IOException; -import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import javax.imageio.ImageIO; import com.google.zxing.BinaryBitmap; import com.google.zxing.BufferedImageLuminanceSource; +import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.GlobalHistogramBinarizer; final class TestCaseUtil { @@ -44,11 +43,7 @@ final class TestCaseUtil { } private static BufferedImage getBufferedImage(String path) throws IOException { - Path file = Paths.get(path); - if (!Files.exists(file)) { - // Support running from project root too - file = Paths.get("core").resolve(file); - } + Path file = AbstractBlackBoxTestCase.buildTestBase(path); return ImageIO.read(file.toFile()); } diff --git a/core/src/test/resources/blackbox/multi-1/1.png b/core/src/test/resources/blackbox/multi-1/1.png new file mode 100644 index 0000000000000000000000000000000000000000..ff0f8b51474a658178ae38b3d3111241f07d858b GIT binary patch literal 10351 zcmch7XIN8P7bb|xMFbQOl`2Y=cIg5F0s;bt-dj|97f_HI<%&pGI-!@)AwnnuLR5P1 zU5KFc5`iQ@ASZL+elzpTGk?DMGk>y^oOS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