From 04e35c02f0656ed2f9813c94c7497f42a9f7a181 Mon Sep 17 00:00:00 2001 From: dswitkin Date: Fri, 18 Apr 2008 14:43:56 +0000 Subject: [PATCH] Changed the black box tests to require an absolute number of images to decode successfully, instead of a percentage, and set the high water mark for each test. git-svn-id: http://zxing.googlecode.com/svn/trunk@367 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../common/AbstractBlackBoxTestCase.java | 26 ++++++++++--------- .../DataMatrixBlackBox1TestCase.java | 2 +- .../zxing/oned/Code128BlackBox1TestCase.java | 2 +- .../zxing/oned/Code39BlackBox1TestCase.java | 2 +- .../oned/Code39ExtendedBlackBox2TestCase.java | 2 +- .../zxing/oned/EAN13BlackBox1TestCase.java | 2 +- .../zxing/oned/EAN8BlackBox1TestCase.java | 2 +- .../zxing/oned/UPCABlackBox1TestCase.java | 2 +- .../zxing/oned/UPCEBlackBox1TestCase.java | 2 +- .../zxing/qrcode/QRCodeBlackBox1TestCase.java | 2 +- .../zxing/qrcode/QRCodeBlackBox2TestCase.java | 2 +- 11 files changed, 24 insertions(+), 22 deletions(-) diff --git a/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java b/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java index 94ccc5e0..f31ea462 100644 --- a/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java +++ b/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java @@ -49,8 +49,7 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { private static final FilenameFilter IMAGE_NAME_FILTER = new FilenameFilter() { public boolean accept(File dir, String name) { String lowerCase = name.toLowerCase(); - return - lowerCase.endsWith(".jpg") || lowerCase.endsWith(".jpeg") || + return lowerCase.endsWith(".jpg") || lowerCase.endsWith(".jpeg") || lowerCase.endsWith(".gif") || lowerCase.endsWith(".png") || lowerCase.endsWith(".url"); } @@ -58,16 +57,16 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { private final File testBase; private final Reader barcodeReader; - private final double passPercent; + private final int mustPassCount; private final BarcodeFormat expectedFormat; protected AbstractBlackBoxTestCase(File testBase, Reader barcodeReader, - double passPercent, + int mustPassCount, BarcodeFormat expectedFormat) { this.testBase = testBase; this.barcodeReader = barcodeReader; - this.passPercent = passPercent; + this.mustPassCount = mustPassCount; this.expectedFormat = expectedFormat; } @@ -99,8 +98,8 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { assertEquals(expectedFormat, result.getBarcodeFormat()); String testImageFileName = testImage.getName(); - File expectedTextFile = - new File(testBase, testImageFileName.substring(0, testImageFileName.indexOf('.')) + ".txt"); + File expectedTextFile = new File(testBase, + testImageFileName.substring(0, testImageFileName.indexOf('.')) + ".txt"); String expectedText = readFileAsString(expectedTextFile); String resultText = result.getText(); @@ -116,16 +115,19 @@ public abstract class AbstractBlackBoxTestCase extends TestCase { result = barcodeReader.decode(source, TRY_HARDER_HINT); } catch (ReaderException re) { if (passed) { - fail("Normal mode succeed but \"try harder\" failed"); + fail("Normal mode succeeded but \"try harder\" failed"); } continue; } - assertEquals("Normal mode succeed but \"try harder\" failed", expectedFormat, result.getBarcodeFormat()); - assertEquals("Normal mode succeed but \"try harder\" failed", expectedText, result.getText()); + assertEquals("Normal mode succeeded but \"try harder\" failed", expectedFormat, + result.getBarcodeFormat()); + assertEquals("Normal mode succeeded but \"try harder\" failed", expectedText, + result.getText()); } - System.out.println(passedCount + " of " + imageFiles.length + " images passed"); - assertTrue("Too many images failed", passedCount >= (int) (imageFiles.length * passPercent)); + System.out.println(passedCount + " of " + imageFiles.length + " images passed (" + + mustPassCount + " required)"); + assertTrue("Too many images failed", passedCount >= mustPassCount); } private static String readFileAsString(File file) throws IOException { diff --git a/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java b/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java index 38204036..f3e690a3 100644 --- a/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/datamatrix/DataMatrixBlackBox1TestCase.java @@ -29,7 +29,7 @@ public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase public DataMatrixBlackBox1TestCase() { // TODO use MultiFormatReader here once Data Matrix decoder is done - super(new File("test/data/blackbox/datamatrix-1"), new DataMatrixReader(), 1.0, BarcodeFormat.DATAMATRIX); + super(new File("test/data/blackbox/datamatrix-1"), new DataMatrixReader(), 7, BarcodeFormat.DATAMATRIX); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/oned/Code128BlackBox1TestCase.java b/core/test/src/com/google/zxing/oned/Code128BlackBox1TestCase.java index 5922e733..c9fec32f 100644 --- a/core/test/src/com/google/zxing/oned/Code128BlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/oned/Code128BlackBox1TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class Code128BlackBox1TestCase extends AbstractBlackBoxTestCase { public Code128BlackBox1TestCase() { - super(new File("test/data/blackbox/code128-1"), new MultiFormatReader(), 1.0, BarcodeFormat.CODE_128); + super(new File("test/data/blackbox/code128-1"), new MultiFormatReader(), 5, BarcodeFormat.CODE_128); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/oned/Code39BlackBox1TestCase.java b/core/test/src/com/google/zxing/oned/Code39BlackBox1TestCase.java index 204c976e..ee68b51e 100644 --- a/core/test/src/com/google/zxing/oned/Code39BlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/oned/Code39BlackBox1TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class Code39BlackBox1TestCase extends AbstractBlackBoxTestCase { public Code39BlackBox1TestCase() { - super(new File("test/data/blackbox/code39-1"), new MultiFormatReader(), 1.0, BarcodeFormat.CODE_39); + super(new File("test/data/blackbox/code39-1"), new MultiFormatReader(), 4, BarcodeFormat.CODE_39); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java b/core/test/src/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java index 55cbf59b..270524e7 100644 --- a/core/test/src/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java +++ b/core/test/src/com/google/zxing/oned/Code39ExtendedBlackBox2TestCase.java @@ -27,7 +27,7 @@ import java.io.File; public final class Code39ExtendedBlackBox2TestCase extends AbstractBlackBoxTestCase { public Code39ExtendedBlackBox2TestCase() { - super(new File("test/data/blackbox/code39-2"), new Code39Reader(false, true), 1.0, BarcodeFormat.CODE_39); + super(new File("test/data/blackbox/code39-2"), new Code39Reader(false, true), 2, BarcodeFormat.CODE_39); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/oned/EAN13BlackBox1TestCase.java b/core/test/src/com/google/zxing/oned/EAN13BlackBox1TestCase.java index d98db59a..29fb9c2e 100644 --- a/core/test/src/com/google/zxing/oned/EAN13BlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/oned/EAN13BlackBox1TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class EAN13BlackBox1TestCase extends AbstractBlackBoxTestCase { public EAN13BlackBox1TestCase() { - super(new File("test/data/blackbox/ean13-1"), new MultiFormatReader(), 0.66, BarcodeFormat.EAN_13); + super(new File("test/data/blackbox/ean13-1"), new MultiFormatReader(), 25, BarcodeFormat.EAN_13); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/oned/EAN8BlackBox1TestCase.java b/core/test/src/com/google/zxing/oned/EAN8BlackBox1TestCase.java index 009a5470..2cd3a1c8 100644 --- a/core/test/src/com/google/zxing/oned/EAN8BlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/oned/EAN8BlackBox1TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class EAN8BlackBox1TestCase extends AbstractBlackBoxTestCase { public EAN8BlackBox1TestCase() { - super(new File("test/data/blackbox/ean8-1"), new MultiFormatReader(), 1.0, BarcodeFormat.EAN_8); + super(new File("test/data/blackbox/ean8-1"), new MultiFormatReader(), 8, BarcodeFormat.EAN_8); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/oned/UPCABlackBox1TestCase.java b/core/test/src/com/google/zxing/oned/UPCABlackBox1TestCase.java index 7d099d43..9f3f0c0d 100644 --- a/core/test/src/com/google/zxing/oned/UPCABlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/oned/UPCABlackBox1TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class UPCABlackBox1TestCase extends AbstractBlackBoxTestCase { public UPCABlackBox1TestCase() { - super(new File("test/data/blackbox/upca-1"), new MultiFormatReader(), 0.5, BarcodeFormat.UPC_A); + super(new File("test/data/blackbox/upca-1"), new MultiFormatReader(), 14, BarcodeFormat.UPC_A); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/oned/UPCEBlackBox1TestCase.java b/core/test/src/com/google/zxing/oned/UPCEBlackBox1TestCase.java index c4c93c82..56c487e5 100644 --- a/core/test/src/com/google/zxing/oned/UPCEBlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/oned/UPCEBlackBox1TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class UPCEBlackBox1TestCase extends AbstractBlackBoxTestCase { public UPCEBlackBox1TestCase() { - super(new File("test/data/blackbox/upce-1"), new MultiFormatReader(), 1.0, BarcodeFormat.UPC_E); + super(new File("test/data/blackbox/upce-1"), new MultiFormatReader(), 3, BarcodeFormat.UPC_E); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java b/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java index 801f626e..a0cdba91 100644 --- a/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java +++ b/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox1TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class QRCodeBlackBox1TestCase extends AbstractBlackBoxTestCase { public QRCodeBlackBox1TestCase() { - super(new File("test/data/blackbox/qrcode-1"), new MultiFormatReader(), 0.5, BarcodeFormat.QR_CODE); + super(new File("test/data/blackbox/qrcode-1"), new MultiFormatReader(), 16, BarcodeFormat.QR_CODE); } } \ No newline at end of file diff --git a/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java b/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java index f1ecdd5a..4c2f0dc5 100644 --- a/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java +++ b/core/test/src/com/google/zxing/qrcode/QRCodeBlackBox2TestCase.java @@ -28,7 +28,7 @@ import java.io.File; public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase { public QRCodeBlackBox2TestCase() { - super(new File("test/data/blackbox/qrcode-2"), new MultiFormatReader(), 1.0, BarcodeFormat.QR_CODE); + super(new File("test/data/blackbox/qrcode-2"), new MultiFormatReader(), 10, BarcodeFormat.QR_CODE); } } \ No newline at end of file -- 2.20.1