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");
}
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;
}
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();
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 {
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
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
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
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
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
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
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
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
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
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